Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Unit test for Custom Application #3408

Merged
merged 2 commits into from
Sep 25, 2019
Merged

Conversation

dellis1972
Copy link
Contributor

@dellis1972 dellis1972 commented Jul 30, 2019

Context #2730

This commit adds a unit test to make sure that we can debug custom applications.
It did expose a slight issue with our enhanced fast deployment. One of the requirements for custom applications working is that the java classes for the custom app MUST be in the classes.dex file in the apk. As a result when using enhanced fast deployment, we can't load the application because not even the MultiDexLoader has been loaded. So for that to work will need to somehow figure out how to pick out just the custom app dependencies and put them into the apk.

All other development modes work fine, so we should add the tests anyway. We can updated the tests later once the enhanced fast deployment issue has been fixed.

@dellis1972
Copy link
Contributor Author

Weird. In the Enhanced Fast Dev mode, CustomApplications do not work.

All the pieces are in place. But it seems despite the mono.android.MultiDexLoader being in place, the system still cannot find the custom application.

I guess it needs to be in the app :(

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="UnnamedProject.UnnamedProject">
  <uses-sdk android:minSdkVersion="24" android:targetSdkVersion="29" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  <application android:label="UnnamedProject" android:name="md52d9cf6333b8e95e8683a477bc589eda5.MyApplication" android:allowBackup="true" android:icon="@drawable/icon" android:debuggable="true">
    <activity android:icon="@drawable/icon" android:label="UnnamedProject" android:name="md52d9cf6333b8e95e8683a477bc589eda5.MainActivity">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <provider android:name="mono.android.MultiDexLoader" android:exported="false" android:initOrder="1999999999" android:authorities="UnnamedProject.UnnamedProject.mono.android.MultiDexLoader.__mono_init__" />
    <provider android:name="mono.MonoRuntimeProvider" android:exported="false" android:initOrder="1999999998" android:authorities="UnnamedProject.UnnamedProject.mono.MonoRuntimeProvider.__mono_init__" />
    <provider android:name="mono.android.ResourcePatcher" android:exported="false" android:initOrder="1999999997" android:authorities="UnnamedProject.UnnamedProject.mono.android.ResourcePatcher.__mono_init__" />
    <!--suppress ExportedReceiver-->
    <receiver android:name="mono.android.Seppuku">
      <intent-filter>
        <action android:name="mono.android.intent.action.SEPPUKU" />
        <category android:name="mono.android.intent.category.SEPPUKU.UnnamedProject.UnnamedProject" />
      </intent-filter>
    </receiver>
  </application>
</manifest>
Process: UnnamedProject.UnnamedProject, PID: 20937
08-21 17:40:54.751 20937 20937 E AndroidRuntime: java.lang.RuntimeException: Unable to instantiate application md52d9cf6333b8e95e8683a477bc589eda5.MyApplication: java.lang.ClassNotFoundException: Didn't find class "md52d9cf6333b8e95e8683a477bc589eda5.MyApplication" on path: DexPathList[[zip file "/data/app/UnnamedProject.UnnamedProject-w70tvDKkWRyPCr0o_vsJJg==/base.apk"],nativeLibraryDirectories=[/data/app/UnnamedProject.UnnamedProject-w70tvDKkWRyPCr0o_vsJJg==/lib/x86, /data/app/UnnamedProject.UnnamedProject-w70tvDKkWRyPCr0o_vsJJg==/base.apk!/lib/x86, /system/lib]]
08-21 17:40:54.751 20937 20937 E AndroidRuntime: 	at android.app.LoadedApk.makeApplication(LoadedApk.java:1069)
08-21 17:40:54.751 20937 20937 E AndroidRuntime: 	at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5842)
08-21 17:40:54.751 20937 20937 E AndroidRuntime: 	at android.app.ActivityThread.access$1100(ActivityThread.java:199)
08-21 17:40:54.751 20937 20937 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
08-21 17:40:54.751 20937 20937 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:106)
08-21 17:40:54.751 20937 20937 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:193)
08-21 17:40:54.751 20937 20937 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6669)
08-21 17:40:54.751 20937 20937 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
08-21 17:40:54.751 20937 20937 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
08-21 17:40:54.751 20937 20937 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
08-21 17:40:54.751 20937 20937 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "md52d9cf6333b8e95e8683a477bc589eda5.MyApplication" on path: DexPathList[[zip file "/data/app/UnnamedProject.UnnamedProject-w70tvDKkWRyPCr0o_vsJJg==/base.apk"],nativeLibraryDirectories=[/data/app/UnnamedProject.UnnamedProject-w70tvDKkWRyPCr0o_vsJJg==/lib/x86, /data/app/UnnamedProject.UnnamedProject-w70tvDKkWRyPCr0o_vsJJg==/base.apk!/lib/x86, /system/lib]]
08-21 17:40:54.751 20937 20937 E AndroidRuntime: 	at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
08-21 17:40:54.751 20937 20937 E AndroidRuntime: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
08-21 17:40:54.751 20937 20937 E AndroidRuntime: 	at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
08-21 17:40:54.751 20937 20937 E AndroidRuntime: 	at android.app.AppComponentFactory.instantiateApplication(AppComponentFactory.java:50)
08-21 17:40:54.751 20937 20937 E AndroidRuntime: 	at android.app.Instrumentation.newApplication(Instrumentation.java:1120)
08-21 17:40:54.751 20937 20937 E AndroidRuntime: 	at android.app.LoadedApk.makeApplication(LoadedApk.java:1061)
08-21 17:40:54.751 20937 20937 E AndroidRuntime: 	... 9 more

@dellis1972 dellis1972 force-pushed the Issue2730 branch 2 times, most recently from e447af4 to 5a075fb Compare September 4, 2019 14:50
@dellis1972 dellis1972 marked this pull request as ready for review September 5, 2019 09:14
@dellis1972 dellis1972 requested a review from jonpryor as a code owner September 5, 2019 09:14
@dellis1972 dellis1972 force-pushed the Issue2730 branch 3 times, most recently from 80237da to 152fa5c Compare September 10, 2019 09:44
@dellis1972 dellis1972 removed the do-not-merge PR should not be merged. label Sep 10, 2019
@dellis1972
Copy link
Contributor Author

macOS PR Release failure is run-api-compatibility-tests FAILED, status: 2. That doesn't look related.

@jonpryor
Copy link
Member

In the most recent AzDO rebuild, the emulator failed to start. :-(

Rebuilding: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3046017&view=results

@dellis1972
Copy link
Contributor Author

Designer tests are doing this Custom controls are not enabled in the test session, bailing out early.
It should not be related as this is just adding a unit test.

@dellis1972 dellis1972 merged commit 2d040aa into dotnet:master Sep 25, 2019
@dellis1972 dellis1972 deleted the Issue2730 branch September 25, 2019 14:51
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants