ApplicationClass ClassNotFoundException - java

I'm using the application class , so I had to create the manifest file, as follows:
<application
android.name="com.moonae.android.common.ApplicationClass"
android.icon="#drawble/ic_launcher"
android.largeHeap="true"
....>
<activity..../>
I have to work normally without problems when testing , often the error occurred in the Google Play Store error report.
But the error report is posted on the Android version 4.4 , I even tested at 4.4 operate normally.
If the person experiencing this problem help me.
java.lang.RuntimeException: Unable to instantiate application com.moonae.android.common.ApplicationClass: java.lang.ClassNotFoundException: Didn't find class "com.culturelandnew.android.common.ApplicationClass" on path: DexPathList[[],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:516)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4524)
at android.app.ActivityThread.access$1500(ActivityThread.java:163)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5335)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.moonae.android.common.ApplicationClass" on path: DexPathList[[],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.Instrumentation.newApplication(Instrumentation.java:993)
at android.app.LoadedApk.makeApplication(LoadedApk.java:511)
... 11 more

<application
android.name="com.moonae.android.common.ApplicationClass"
android.icon="#drawble/ic_launcher"
android.largeHeap="true"
....>
<activity..../>
is this a typo? i have not seen this before i mean android.name to android:name..btw
quick suggestion, remove your application tag, and use the eclipse gui side to search the application class and reference it.. mostly it references the it without package name included.. like this.. =>
<application
android:name="ApplicationClass"
android:icon="#drawble/ic_launcher"
android:largeHeap="true"
....>

Related

java.lang.RuntimeException: Failure delivering result ResultInfo{...} to activity {....FacebookSignUp}: java.lang.NullPointerException:

In the Google Play Console pre-launch report, I the "STABILITY" section, I have this error that I need to fix:
Galaxy S9
Test ID: 2
Test Duration: 300 seconds
Model Name: Galaxy S9
Manufacturer: Samsung
Android Version: Android 8.0
Locale: es_US
Screen Size: 1080 × 2220
Screen Density (dpi): 480
RAM: 4096 MB
OpenGL ES Version: 3.2
Native Platform: armeabi-v7a
CPU Make: Qualcomm
CPU Model: SDM845
Issue: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=32665, result=0, data=null} to activity {[...].FacebookSignUp}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.getStringExtra(java.lang.String)' on a null object reference
FATAL EXCEPTION: main
Process: [...], PID: 25180
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=32665, result=0, data=null} to activity {[...].FacebookSignUp}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.getStringExtra(java.lang.String)' on a null object reference
at android.app.ActivityThread.deliverResults(ActivityThread.java:4489)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4532)
at android.app.ActivityThread.-wrap20(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1752)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.getStringExtra(java.lang.String)' on a null object reference
at com.easy.facebook.android.facebook.FBLoginManager.loginSuccess(FBLoginManager.java:99)
at [...].FacebookSignUp.onActivityResult(FacebookSignUp.java:187)
at android.app.Activity.dispatchActivityResult(Activity.java:7539)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4485)
... 9 more
I suspect that this problem might be happening because my Facebook library is too old. In my app/build.gradle I am using this Facebook library:
implementation 'com.facebook.android:facebook-android-sdk:3.23.1'
I am sure it is very old and most likely deprecated in many ways. It still works though, but it might be the cause of this error that I see. Also, I am using this:
dependencies {
...
implementation files('libs/easyfacebookandroidsdk_2.3.jar')
....
}
That Facebook library must be the cause. Any ideas about fixing that NullPointerException that I see in the error? I guess the best should be for me to upgrade those very old Facebook libraries.
The problem was not Facebook. After examining the logs, the real problem was this:
E/AndroidRuntime: FATAL EXCEPTION: Thread-6
Process: [package name], PID: 5893
java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/impl/client/DefaultHttpClient;
at com.couponclub.Util.Util$1.run(Util.java:235)
at java.lang.Thread.run(Thread.java:764)
Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.http.impl.client.DefaultHttpClient" on path: DexPathList[[zip file "/data/app/[package name]-3cwAF4cAFytf561aNx4V2Q==/base.apk", zip file "/data/app/[package name]-3cwAF4cAFytf561aNx4V2Q==/split_lib_dependencies_apk.apk", zip file "/data/app/[package name]-3cwAF4cAFytf561aNx4V2Q==/split_lib_resources_apk.apk", zip file "/data/app/[package name]-3cwAF4cAFytf561aNx4V2Q==/split_lib_slice_0_apk.apk", zip file "/data/app/[package name]-3cwAF4cAFytf561aNx4V2Q==/split_lib_slice_1_apk.apk", zip file "/data/app/[package name]-3cwAF4cAFytf561aNx4V2Q==/split_lib_slice_2_apk.apk", zip file "/data/app/[package name]-3cwAF4cAFytf561aNx4V2Q==/split_lib_slice_3_apk.apk", zip file "/data/app/[package name]-3cwAF4cAFytf561aNx4V2Q==/split_lib_slice_4_apk.apk", zip file "/data/app/[package name]-3cwAF4cAFytf561aNx4V2Q==/split_lib_slice_5_apk.apk", zip file "/data/app/[package name]-3cwAF4cAFytf561aNx4V2Q==/split_lib_slice_6_apk.apk", zip file "/data/app/[package name]-3cwAF4cAFytf561aNx4V2Q==/split_lib_slice_7_apk.apk", zip file "/data/app/[package name]-3cwAF4cAFytf561aNx4V2Q==/split_lib_slice_8_apk.apk", zip file "/data/app/[package name]-3cwAF4cAFytf561aNx4V2Q==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/[package name]-3cwAF4cAFytf561aNx4V2Q==/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.couponclub.Util.Util$1.run(Util.java:235)
at java.lang.Thread.run(Thread.java:764)
Suppressed: java.io.IOException: No original dex files found for dex location /data/app/[package name]-3cwAF4cAFytf561aNx4V2Q==/split_lib_resources_apk.apk
at dalvik.system.DexFile.openDexFileNative(Native Method)
at dalvik.system.DexFile.openDexFile(DexFile.java:354)
at dalvik.system.DexFile.<init>(DexFile.java:101)
at dalvik.system.DexFile.<init>(DexFile.java:75)
at dalvik.system.DexPathList.loadDexFile(DexPathList.java:394)
at dalvik.system.DexPathList.makeDexElements(DexPathList.java:354)
at dalvik.system.DexPathList.<init>(DexPathList.java:164)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:74)
at dalvik.system.BaseDexClassLoader.<init>(BaseDexClassLoader.java:65)
at dalvik.system.PathClassLoader.<init>(PathClassLoader.java:64)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:73)
at com.android.internal.os.ClassLoaderFactory.createClassLoader(ClassLoaderFactory.java:88)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:74)
at android.app.ApplicationLoaders.getClassLoader(ApplicationLoaders.java:40)
at android.app.LoadedApk.createOrUpdateClassLoaderLocked(LoadedApk.java:727)
at android.app.LoadedApk.getClassLoader(LoadedApk.java:810)
at android.app.LoadedApk.getResources(LoadedApk.java:1032)
at android.app.ContextImpl.createAppContext(ContextImpl.java:2345)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5749)
at android.app.ActivityThread.access$1100(ActivityThread.java:199)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1650)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
The solution was to go include the following line inside of the <application> section of my AndroidManifest.xml:
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
This is explained at https://developer.android.com/about/versions/pie/android-9.0-changes-28#apache-p.

ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" after androidx migration

I'm trying to move to migrate to androidx. I used the migration tool in Android Studio. When I do this I get the following stacktrace when I run my app.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.peerke.outdoorpuzzlegame.debug, PID: 10901
java.lang.RuntimeException: Unable to get provider android.support.v4.content.FileProvider: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" on path: DexPathList[[zip file "/data/app/com.peerke.outdoorpuzzlegame.debug-IBtFsngoLqc-cQb_hOO5wQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.peerke.outdoorpuzzlegame.debug-IBtFsngoLqc-cQb_hOO5wQ==/lib/x86, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:6376)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5932)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5847)
at android.app.ActivityThread.access$1000(ActivityThread.java:198)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1637)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6649)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:826)
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.content.FileProvider" on path: DexPathList[[zip file "/data/app/com.peerke.outdoorpuzzlegame.debug-IBtFsngoLqc-cQb_hOO5wQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.peerke.outdoorpuzzlegame.debug-IBtFsngoLqc-cQb_hOO5wQ==/lib/x86, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateProvider(AppComponentFactory.java:121)
at androidx.core.app.CoreComponentFactory.instantiateProvider(CoreComponentFactory.java:62)
at android.app.ActivityThread.installProvider(ActivityThread.java:6360)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5932) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5847) 
at android.app.ActivityThread.access$1000(ActivityThread.java:198) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1637) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loop(Looper.java:164) 
at android.app.ActivityThread.main(ActivityThread.java:6649) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:826) 
The exception is correct. android.support.v4.content.FileProvider doesn't exist in my app. But androidx.core.content.FileProvider is included in my app.
The big question is why does it want to load the old version of FileProvider?
Thanks to #CommonsWare
More explanation:
What to do, find the android.support.v4.FileProvider in your <provider> in AndroidManifest.xml.
Change it to androidx.core.content.FileProvider
In manifiest.xml file simply change this
<provider
android:name="android.support.v4.content.FileProvider"
.....
</provider>
To this one
<provider
android:name="androidx.core.content.FileProvider"
......
</provider>
Or Simply
Go to Refactor (Studio -> Menu -> Refactor)
Click the Migrate to AndroidX.
it's working.
why does it want to load the old version of FileProvider?
Based on the stack trace, perhaps you are still using the old package name in the <provider> element in the manifest.

Activity class not found even though the class appears in dex disassembly

I'm developing an Android app (let's call it AppName) in Unity 2017.3 Beta 1. I need a custom Activity to run some Java code on Startup. I have the code for the AppNameActivity in a separate project which uses gradle to package the Activity into the AppName.jar file which is then dropped into Unity's AppName/Assets/Plugins/Android folder, along with a custom AndroidManifest.xml which referencet it. I uses Unity's Build and Run feature (Build System: Gradle, Development Build).
When I start the app on my Android device, it crashes instantly. It seems as if the Activity class was missing, but on closer inspection, it is actually there.
Via adb logcat I can obtain this error:
V/ActivityThread(24831): Handling launch of ActivityRecord{2609126c token=android.os.BinderProxy#2101f035 {de.companyname.appname.rebuild/de.companyname.appname.rebuild.AppNameActivity}}
D/OpenGLRenderer(23986): Flushing caches (mode 0)
D/OpenGLRenderer(23986): Flushing caches (mode 0)
I/art (24831): Rejecting re-init on previously-failed class java.lang.Class<de.companyname.appname.rebuild.AppNameActivity>
D/AndroidRuntime(24831): Shutting down VM
E/AndroidRuntime(24831): FATAL EXCEPTION: main
E/AndroidRuntime(24831): Process: de.companyname.appname.rebuild, PID: 24831
E/AndroidRuntime(24831): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{de.companyname.appname.rebuild/de.companyname.appname.rebuild.AppNameActivity}: java.lang.ClassNotFoundException: Didn't find class "de.companyname.appname.rebuild.AppNameActivity" on path: DexPathList[[zip file "/data/app/de.companyname.appname.rebuild-2/base.apk"],nativeLibraryDirectories=[/data/app/de.companyname.appname.rebuild-2/lib/arm, /vendor/lib, /system/lib]]
E/AndroidRuntime(24831): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2381)
E/AndroidRuntime(24831): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2532)
E/AndroidRuntime(24831): at android.app.ActivityThread.access$900(ActivityThread.java:169)
E/AndroidRuntime(24831): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1421)
E/AndroidRuntime(24831): at android.os.Handler.dispatchMessage(Handler.java:111)
E/AndroidRuntime(24831): at android.os.Looper.loop(Looper.java:194)
E/AndroidRuntime(24831): at android.app.ActivityThread.main(ActivityThread.java:5562)
E/AndroidRuntime(24831): at java{de.companyname.appname.rebuild/de.companyname.appname.rebuild.AppNameActivity}.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(24831): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(24831): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:968)
E/AndroidRuntime(24831): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:763)
E/AndroidRuntime(24831): Caused by: java.lang.ClassNotFoundException: Didn't find class "de.companyname.appname.rebuild.AppNameActivity" on path: DexPathList[[zip file "/data/app/de.companyname.appname.rebuild-2/base.apk"],nativeLibraryDirectories=[/data/app/de.companyname.appname.rebuild-2/lib/arm, /vendor/lib, /system/lib]]
E/AndroidRuntime(24831): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(24831): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime(24831): at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/AndroidRuntime(24831): at android.app.Instrumentation.newActivity(Instrumentation.java:1070)
E/AndroidRuntime(24831): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2371)
E/AndroidRuntime(24831): ... 10 more
E/AndroidRuntime(24831): Suppressed: java.lang.NoClassDefFoundError: de.companyname.appname.rebuild.AppNameActivity
E/AndroidRuntime(24831): at dalvik.system.DexFile.defineClassNative(Native Method)
E/AndroidRuntime(24831): at dalvik.system.DexFile.defineClass(DexFile.java:226)
E/AndroidRuntime(24831): at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
E/AndroidRuntime(24831): at dalvik.system.DexPathList.findClass(DexPathList.java:321)
E/AndroidRuntime(24831): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
E/AndroidRuntime(24831): ... 14 more
E/AndroidRuntime(24831): Suppressed: java.lang.ClassNotFoundException: de.companyname.appname.rebuild.AppNameActivity
E/AndroidRuntime(24831): at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(24831): at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime(24831): at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime(24831): at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime(24831): ... 13 more
E/AndroidRuntime(24831): Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
The relevant part of my AndroidManifest.xml:
<application android:theme="#style/UnityThemeSelector" android:icon="#drawable/app_icon" android:label="#string/app_name" android:isGame="false" android:banner="#drawable/app_banner">
<activity android:label="#string/app_name" android:screenOrientation="fullSensor" android:launchMode="singleTask" android:configChanges="mcc|mnc|locale|touchscreen|keyboard|keyboardHidden|navigation|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|fontScale|layoutDirection" android:name="de.companyname.appname.rebuild.AppNameActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
</activity>
(...)
</application>
Here's the output of dexdump, executed on the Android device via adb shell with the argument /data/app/de.companyname.appname.rebuild-2/base.apk.
Processing './base.apk'...
Opened './base.apk', DEX version '035'
(...)
Class #69 -
Class descriptor : 'Lde/companyname/appname/rebuild/AppNameActivity;'
Access flags : 0x0001 (PUBLIC)
Superclass : 'Lde/companyname/appname/rebuild/UnityPlayerActivity;'
Interfaces -
Static fields -
#0 : (in Lde/companyname/appname/rebuild/AppNameActivity;)
name : 'ACTION_USB_PERMISSION'
type : 'Ljava/lang/String;'
access : 0x001a (PRIVATE STATIC FINAL)
#1 : (in Lde/companyname/appname/rebuild/AppNameActivity;)
name : 'TAG'
type : 'Ljava/lang/String;'
access : 0x001a (PRIVATE STATIC FINAL)
Instance fields -
#0 : (in Lde/companyname/appname/rebuild/AppNameActivity;)
name : 'mUsbManager'
type : 'Landroid/hardware/usb/UsbManager;'
access : 0x0002 (PRIVATE)
#1 : (in Lde/companyname/appname/rebuild/AppNameActivity;)
name : 'mUsbReceiver'
type : 'Landroid/content/BroadcastReceiver;'
access : 0x0012 (PRIVATE FINAL)
#2 : (in Lde/companyname/appname/rebuild/AppNameActivity;)
name : 'validProductNames'
type : 'Ljava/util/Collection;'
access : 0x0002 (PRIVATE)
Direct methods -
#0 : (in Lde/companyname/appname/rebuild/AppNameActivity;)
name : '<init>'
type : '()V'
access : 0x10001 (PUBLIC CONSTRUCTOR)
code -
registers : 4
ins : 1
outs : 2
insns size : 32 16-bit code units
catches : (none)
positions :
0x0000 line=27
0x0003 line=22
0x000a line=25
0x0018 line=28
0x001f line=29
locals :
0x0000 - 0x0020 reg=3 this Lde/companyname/appname/rebuild/AppNameActivity;
(...)
I also used the tool AndroidSdk/tools/bin/apkanalyzer dex packages ~/src/appname/UnityExport.apk to get a disassembly on my dev machin, which yields:
sh: 0: getcwd() failed: No such file or directory
P d 465 944 66105 <TOTAL>
P d 420 454 49362 com
(...)
C d 8 10 1067 de.companyname.appname.rebuild.AppNameActivity
M d 1 1 119 de.companyname.appname.rebuild.AppNameActivity <init>()
(...)
So I'm rather sure that the class de.companyname.appname.rebuild.AppNameActivity is present on the device.
Update:
I was worried about the package being mentioned twice in a row in the error log: {de.companyname.appname.rebuild/de.companyname.appname.rebuild.AppNameActivity} so I changed the value in the manifest from android:name="de.companyname.appname.rebuild.AppNameActivity" to android:name=".AppNameActivity". Still, I get exactly the same error message.
I found the solution to my own problem: I was missing a superclass.
When I tried to make a release build (before, I always tried the debug build), I got several error messages, including this line:
Warning: de.companyname.appname.rebuild.AppNameActivity: can't find superclass or interface de.companyname.appname.rebuild.UnityPlayerActivity
In fact, I had made a mistake while bundling AppName.jar, so that the superclass was missing. I'm still surprised about the rather unspecific runtime error from the AndroidRuntime which only mentioned AppNameActivity.
I rebuilt the jar and the release build and now this error is fixed, AppNameActivity is loaded and it's constructor executed (and then crashes during execution due to some other problems which are beyond the scope).
For a moment, I was still unsure about this whole thing because I looked at the old output of dexdump (which I quoted partially in my question) which confirmed the presence of UnityPlayerActivity. Upon closer inspection, I noticed that com.unity3d.player.UnityPlayerActivity was included, but the actual superclass was de.companyname.appname.rebuild.UnityPlayerActivity

Android App Crashes on Real Device If apk is manually installed

My Application is running fine in Emulators and even in real devices installed by android studio for debugging purpose, but it is crashing if installed manually using apk file.
I am ready to paste any other codes, like Activity if required.
Here is the logcat:
04-14 12:20:44.392 6220-6220/? I/art: Late-enabling -Xcheck:jni
04-14 12:20:44.465 6220-6220/test.planner W/System: ClassLoader referenced unknown path: /data/app/test.planner-1/lib/arm
04-14 12:20:44.467 6220-6220/test.planner I/InstantRun: starting instant run server: is main process
04-14 12:20:44.470 6220-6220/test.planner D/AndroidRuntime: Shutting down VM
04-14 12:20:44.471 6220-6220/test.planner E/AndroidRuntime: FATAL EXCEPTION: main
Process: test.planner, PID: 6220
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{test.planner/test.planner.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "test.planner.MainActivity" on path: DexPathList[[zip file "/data/app/test.planner-1/base.apk"],nativeLibraryDirectories=[/data/app/test.planner-1/lib/arm, /vendor/lib, /system/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.ClassNotFoundException: Didn't find class "test.planner.MainActivity" on path: DexPathList[[zip file "/data/app/test.planner-1/base.apk"],nativeLibraryDirectories=[/data/app/test.planner-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at android.app.Instrumentation.newActivity(Instrumentation.java:1067)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2317)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
at android.app.ActivityThread.-wrap11(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Suppressed: java.lang.ClassNotFoundException: test.planner.MainActivity
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 12 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
Just go to:
Android Studio --> File --> Setting --> Build, execution, deploy --> Instant run.
and disable instant run.
If you just upgraded your android studio.
You will not have this option to disable -> Instant Run. (not on the menu)
Seems like with new android studio and gradle upgrade in order to install an apk you need to properly build it.
Option 1: with gradle from command line
./gradlew :appName:clean
./gradlew :appName:build
Option 2: from android studio
Android Studio -> build -> build APK (or generate sighed APK)
The generated apk can be installed fine on a device.
Note: if you start a new applicate with this version of android studio you will see that when you run from studio there is no apk generated anymore.
I faced the similar problem.
Note the size of Apk, it would be very small in size , this is because of the instant run feature in enabled. Just disable it
May be Android Studio is not including all files in Apk, when we use the instant run to fasten the process.
Any body know why this happening?
Go to :
Android Studio --> File --> Setting --> Build, execution, deploy --> Instant run.
Android Studio --> File --> Setting --> Build, execution, deploy --> Instant run.
and disable instant run.

Vitamio Sample Error - java.lang.UnsatisfiedLinkError: Couldn't load vinit findLibrary returned null

I'm having trouble running the vitamio-sample from https://github.com/yixia/VitamioBundle.
I am building it with Android Studio and it compiles fine and runs, but when it gets to this line:
if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(this))
return;
It throws an exception when I run it on my Nexus 5 (and also on a Galaxy S4):
01-22 11:58:40.759 12323-12323/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: io.vov.vitamio.demo, PID: 12323
java.lang.UnsatisfiedLinkError: Couldn't load vinit from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/io.vov.vitamio.demo-1.apk"],nativeLibraryDirectories=[/data/app-lib/io.vov.vitamio.demo-1, /vendor/lib, /system/lib]]]: findLibrary returned null
at java.lang.Runtime.loadLibrary(Runtime.java:358)
at java.lang.System.loadLibrary(System.java:526)
at io.vov.vitamio.Vitamio.<clinit>(Vitamio.java:258)
at io.vov.vitamio.LibsChecker.checkVitamioLibs(LibsChecker.java:40)
at io.vov.vitamio.demo.VitamioListActivity.onCreate(VitamioListActivity.java:40)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
The exception also happens when I'm running the v4.2.0 tree in my own app.
Any idea what I'm missing? In my own app I pulled the vitamio project into a libraries folder and am referencing it like this:
compile(project(':libraries:vitamio'))
The sample project is left as-is.
I am not sure if there is a cleaner way in the newer version of Vitamino (or gradle). But here is how I got it to work with gradle build tools 0.6.
Added a project to my /libraries directory with the vitamino source/sdk. This has a /libs/armeabi /libs/armeabi-v7a with libvinit.so inside.
In my build.gradle for my main project, reference the library project like:
dependencies {
// other dependencies
compile(project(':libraries:vitamio'))
}
Add the following to the bottom of my build.gradle
task copyNativeLibs(type: Copy) {
from(new File(project(':libraries:vitamio').getProjectDir(), 'libs')) { include '**/*.so' }
into new File(buildDir, 'native-libs')
}
tasks.withType(JavaCompile) { compileTask -> compileTask.dependsOn copyNativeLibs }
clean.dependsOn 'cleanCopyNativeLibs'
tasks.withType(com.android.build.gradle.tasks.PackageApplication) { pkgTask ->
pkgTask.jniDir new File(buildDir, 'native-libs')
}
Then when i run a clean and rebuild it will copy the native libs to the proper spot and include them in the build.

Categories