Bug 12275 - Trial edition splash screen generator breaks if <activity/> is Java code
Summary: Trial edition splash screen generator breaks if <activity/> is Java code
Status: ASSIGNED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 4.8.x
Hardware: PC Mac OS
: Lowest normal
Target Milestone: master
Assignee: Atsushi Eno
URL:
Depends on:
Blocks:
 
Reported: 2013-05-16 23:53 UTC by Jonathan Pryor
Modified: 2016-09-20 12:58 UTC (History)
3 users (show)

Tags: XATriaged
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 12275 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
ASSIGNED

Description Jonathan Pryor 2013-05-16 23:53:27 UTC
Context: http://forums.xamarin.com/discussion/3981/cant-create-main-screen-launcher

If you've started a Trial, then a splash screen is generated. If AndroidManifest.xml contains a hand-written <activity/> element that is not a fully-qualified type name, then the generated splash screen code doesn't compile.
Comment 1 Atsushi Eno 2013-06-21 05:00:24 UTC
That is actually NOTABUG.
When a user specifies a name like "SomeActivity" e.g. without qualified name, XA still builds but the app fails at run time saying that it couldn't find the corresponding class. And that result is *expected*.
I have no right idea if ordinal Android build rejects such plain unqualified name at build time or not, but the result that it does not compile is *correct* because it indeed does not exist.

Something similar applies to dot-started name (e.g. ".SomeActivity"). Regardless of it is Trial or not, XA rejects to build a valid apk for that name. It *builds* some apk, but the results in ClassNotFoundException:

[AndroidRuntime] java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{SplashTest.SplashTest/SplashTest.SplashTest.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "SplashTest.SplashTest.MainActivity" on path: /data/app/SplashTest.SplashTest-1.apk
[AndroidRuntime] 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
[AndroidRuntime] 	at 
<snip>

My wild guess is that it is because we lowercase .NET namespaces into java packages but NOT in our app package names, causing name mismatch.
Comment 2 Jonathan Pryor 2013-06-21 14:56:05 UTC
> XA still builds but the app fails at run time saying that it couldn't find the
> corresponding class. And that result is *expected*.

MAYBE. Or the user has added a .java file which "happens" to contain the appropriately named type, the type is found at runtime, and everything Just Works.

> but the result that it does not compile is *correct* because it indeed does not exist.

It MAY not exist. Then again, it MAY.

(And for further laughter, we can introduce case-sensitivity.)

For example:

1. Create a new project. Name the project My.Example. Note casing.
2. Add a .java to the file, contents:

    package My.Example;
    public class MyActivity extends android.app.Activity {
    }

3. Add Properties\AndroidManifest.xml, and add:

    <activity android:name="MyActivity" android:label="Example" >
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>

4. Build w/ a Trial license. It won't compile, because the generated TrialSplashScreen.java file will have:

    package my.example;

Thus, attempts to reference My.Example.MyActivity will fail.

This is actually a somewhat silly example, as even if (4) were to build, it probably likely _still_ fail because the filesystem is NOT case-sensitive, and thus only _some_ of the .class files will be compiled into the app. (It would work on Linux! ;-)

Lowercase the package name and we'd have something that would more reliably work on case-insensitive systems (OS X, Windows), which might also work as-is. Use ".subpackage.MyActivity" and it would break.

> My wild guess is that it is because we lowercase .NET namespaces into java
> packages but NOT in our app package names, causing name mismatch.

Yup, this is certainly part of it. (It may be all of it!)

However, another way to go would be to just fully-qualify all type references. If the main-launcher //activity/@android:name contains no '.'s or starts with a '.', we could lookup the /manifest/@package value and use it as a prefix. Thus, instead of generating MyActivity.class, we'd generate My.Example.MyActivity.class..
Comment 3 Atsushi Eno 2013-06-27 03:59:51 UTC
As we are not enjoying that boring milestones, we should set priority back once we got "not silly" example.