Nativescript Android build: Unable to instantiate activity ComponentInfo - android

I'm trying to create new Android app with Nativescript Angular, build passes ok, but when I try to run it on my device I get an error:
An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{<my-app-id>/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'com/tns/NativeScriptActivity'
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: com.tns.NativeScriptException: Failed to create JavaScript extend wrapper for class 'com/tns/NativeScriptActivity'
at com.tns.Runtime.createJSInstanceNative(Native Method)
at com.tns.Runtime.createJSInstance(Runtime.java:643)
at com.tns.Runtime.initInstance(Runtime.java:618)
at com.tns.NativeScriptActivity.<init>(NativeScriptActivity.java:12)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1174)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2669)
... 9 more
Reproduction steps:
cd elipay-builds
tns create MyApp --appid <my-app-id> --template ng
cd MyApp
npm install --save-dev nativescript-dev-webpack
npm install
./node_modules/.bin/update-ns-webpack --configs --deps
tns run android
tns build android --bundle
UPDATE 1: I managed to figure out that an issue is somehow connected to the applicationId.
UPDATE 2: If I update id property in my nativescript's package.json file:
{
...
"nativescript": {
"id": "<my-new-app-id>"
},
...
}
I need to assign new applicationId to my app each time I build it. And this is wrong, since stores will recognize my app as different one after the update.
I don't know what else I can try. Please help me.
Thanks :)

Related

Kotlin Multiplatform + Sentry

I want to use Sentry for my Multiplatform Kotlin project.
Sentry for Kotlin Multiplatform
So I was trying to prepare the setup of Sentry with Kotlin Multiplatform.
I was following the guide, made a mavenLocal() build etc.
Now I wanted to add it to the project.
However, when starting my (Android) project, even before starting the onCreate() of the Application I get a crash stating:
Unable to get provider io.sentry.android.core.SentryInitProvider:
java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
So to be clear this happens already when adding api("io.sentry:sentry-kotlin-multiplatform:0.0.1") to the dependencies. Long before the init call.
All I did was:
Configure shared build.gradle.kts and add
val commonMain by getting {
dependencies {
api("io.sentry:sentry-kotlin-multiplatform:0.0.1")
Adding the sample configuration
fun initializeSentry(context: Context) {
Sentry.init(context) { sentryOptions -> setDsnHere... }
}
and in the Android Application:
initializeSentry(this)
Then tried to run it. But I don't even get to the init call.
The configuration should be reached and the initializeSentry(this) block executed. (I can accept if it fails there but I don't even get that far.)
Instead the app fails stating
E/AndroidRuntime: FATAL EXCEPTION: main
Process: xyz, PID: 23056
java.lang.RuntimeException: Unable to get provider io.sentry.android.core.SentryInitProvider: java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
at android.app.ActivityThread.installProvider(ActivityThread.java:7467)
...
even before anything else.
So the mere adding to the gradle file causes the crash already (even if the other code is commented out).
-------- Full Stack trace-------
java.lang.RuntimeException: Unable to get provider io.sentry.android.core.SentryInitProvider: java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
at android.app.ActivityThread.installProvider(ActivityThread.java:7467)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6973)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6744)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loopOnce(Looper.java:201)
at android.os.Looper.loop(Looper.java:288)
at android.app.ActivityThread.main(ActivityThread.java:7872)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
Caused by: java.lang.IllegalArgumentException: DSN is required. Use empty string to disable SDK.
at io.sentry.Sentry.initConfigurations(Sentry.java:201)
at io.sentry.Sentry.init(Sentry.java:170)
at io.sentry.Sentry.init(Sentry.java:118)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:87)
at io.sentry.android.core.SentryAndroid.init(SentryAndroid.java:56)
at io.sentry.android.core.SentryInitProvider.onCreate(SentryInitProvider.java:27)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2451)
at android.content.ContentProvider.attachInfo(ContentProvider.java:2421)
at io.sentry.android.core.SentryInitProvider.attachInfo(SentryInitProvider.java:44)
at android.app.ActivityThread.installProvider(ActivityThread.java:7462)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6973) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6744) 
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2133) 
at android.os.Handler.dispatchMessage(Handler.java:106) 
at android.os.Looper.loopOnce(Looper.java:201) 
at android.os.Looper.loop(Looper.java:288) 
at android.app.ActivityThread.main(ActivityThread.java:7872) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) 
Turns out the manual had forgotten to mention the auto configuration.
Add this line to your Manifest:
<meta-data android:name="io.sentry.auto-init" android:value="false" />
and proceed with the tutorial.
For Reference:
https://github.com/getsentry/sentry-kotlin-multiplatform/issues/45

running python in android app with chaquopy yields fatal error

I'm try to run python code in my android app using Chaquopy, I'm also using the moviepy library (I'm converting a mp4 file to a gif file). When I try to do the conversion I get the following error message:
2019-02-06 15:46:47.586 3924-3924/com.udacity.gradle.builditbigger E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.udacity.gradle.builditbigger, PID: 3924
com.chaquo.python.PyException: AttributeError: module 'moviepy.audio.fx.all' has no attribute 'audio_fadein'
at <python>.moviepy.editor.<module>(<string>:1)
at <python>.moviepy.editor.<module>(editor.py:80)
at <python>.java.android.importer.load_module_impl(importer.py:435)
at <python>.java.android.importer.load_module(importer.py:353)
at <python>.importlib._bootstrap._load_backward_compatible(<frozen importlib._bootstrap>:626)
at <python>.importlib._bootstrap._load_unlocked(<frozen importlib._bootstrap>:656)
at <python>.importlib._bootstrap._find_and_load_unlocked(<frozen importlib._bootstrap>:955)
at <python>.importlib._bootstrap._find_and_load(<frozen importlib._bootstrap>:971)
at <python>.java.chaquopy.import_override(import.pxi:18)
at <python>.gif_convert.<module>(gif_convert.py:1)
at <python>.java.android.importer.load_module_impl(importer.py:435)
at <python>.java.android.importer.load_module(importer.py:353)
at <python>.importlib._bootstrap._load_backward_compatible(<frozen importlib._bootstrap>:626)
at <python>.importlib._bootstrap._load_unlocked(<frozen importlib._bootstrap>:656)
at <python>.importlib._bootstrap._find_and_load_unlocked(<frozen importlib._bootstrap>:955)
at <python>.importlib._bootstrap._find_and_load(<frozen importlib._bootstrap>:971)
at <python>.importlib._bootstrap._gcd_import(<frozen importlib._bootstrap>:994)
at <python>.importlib.import_module(__init__.py:126)
at <python>.chaquopy_java.Java_com_chaquo_python_Python_getModule(chaquopy_java.pyx:154)
at com.chaquo.python.Python.getModule(Native Method)
at com.udacity.gradle.builditbigger.newPost.visualMediaPost.VisualMediaPostFragment.moveFile(VisualMediaPostFragment.java:247)
at com.udacity.gradle.builditbigger.camera.LifeCycleCamera.getFilePath(LifeCycleCamera.java:1161)
at com.udacity.gradle.builditbigger.camera.LifeCycleCamera.stopRecordingVideo(LifeCycleCamera.java:1078)
at com.udacity.gradle.builditbigger.newPost.visualMediaPost.VisualMediaPostFragment.lambda$onCreateView$5(VisualMediaPostFragment.java:162)
at com.udacity.gradle.builditbigger.newPost.visualMediaPost.-$$Lambda$VisualMediaPostFragment$WS1G2y9p8sE-re_eOWFa7Rr0OCU.onClick(Unknown Source:4)
at android.view.View.performClick(View.java:6897)
at android.view.View$PerformClick.run(View.java:26089)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6940)
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)
I've found a fix for this problem (it involves changing the python code that would normally be generated by android studio, so any changes made to the python files will be overwritten during build time.
The python code is shown below
from moviepy.editor import VideoFileClip
def convert(path):
clip = VideoFileClip(path)
return clip.write_gif("output.gif", fps=24)
The java code used to start the pyhton code:
Python.start(new AndroidPlatform(getActivity()));
Python py = Python.getInstance();
PyObject gifConvert = py.getModule("gif_convert");
PyObject gif = gifConvert.callAttr("convert", file.getAbsolutePath());
Log.i("gif type", gif.toString());
Any help would be greatly appreciated.
Older versions of Chaquopy had a problem with pkgutil.iter_modules. This has been fixed in Chaquopy 6.2.1.

CLJSRN Release Build Runtime Failure

I inherited this CLJS React Native codebase and I'm trying to upgrade the Android SDK to v26 with React 16.4 and RN 0.56. The debug build works great but the release build fails when starting up with the following call stack:
2018-11-21 10:31:30.731 16727-16790/? E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
Process: XXX, PID: 16727
com.facebook.react.common.JavascriptException: Can't find variable: a, stack:
<unknown>#12:60553
<unknown>#12:60366
<unknown>#12:518500
c#2:822
i#2:394
t#2:324
global code#322:8
at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError(ExceptionsManagerModule.java:54)
at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException(ExceptionsManagerModule.java:38)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:193)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:764)
Any ideas on how to get the non-minified version of the call stack? Is the minification done by the cljs to js compiler? Or the RN bundler/packager?
I'm currently using advanced optimizations on the cljs to js compiler. If I switch it to whitespace optimizations, then I get a build error
transform[stderr]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
I can work around it by doing the bundling separately
node --expose-gc --max_old_space_size=4096 ./node_modules/react-native/local-cli/cli.js bundle --verbose --platform android --dev true --reset-cache --entry-file index.android.js --bundle-output /usr/src/app/android/app/build/intermediates/assets/release/index.android.bundle --assets-dest /usr/src/app/android/app/build/intermediates/res/merged/release
But I hit another failure
Unable to load script from assets 'index.android.bundle'.
Any ideas what else I can try?
Update 1: The "Unable to load script from assets 'index.android.bundle'." error message was caused by the index.android.bundle file being placed in the wrong folder. The following command worked:
node --expose-gc --max_old_space_size=4096 ./node_modules/react-native/local-cli/cli.js bundle --verbose --platform android --dev true --reset-cache --entry-file index.android.js --bundle-output /usr/src/app/android/app/src/main/assets/index.android.bundle --assets-dest /usr/src/app/android/app/src/main/res/
The unminified call stack looks like:
2018-11-27 15:07:00.740 23765-23859/? E/ReactNativeJNI: Got JS Exception: Can't find variable: document (index.android.bundle:1632)
2018-11-27 15:07:00.740 23765-23859/? E/ReactNativeJNI: Got JS Stack: index.android.bundle:1632:43
loadModuleImplementation#index.android.bundle:162:14
guardedLoadModule#index.android.bundle:83:47
metroRequire#index.android.bundle:72:79
global code#index.android.bundle:1639:8
2018-11-27 15:07:00.749 23765-23859/? E/AndroidRuntime: FATAL EXCEPTION: mqt_js
Process: XXX, PID: 23765
java.lang.RuntimeException: com.facebook.react.devsupport.JSException: Can't find variable: document (index.android.bundle:1632)
at com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler.handleException(DefaultNativeModuleCallExceptionHandler.java:22)
at com.facebook.react.devsupport.DisabledDevSupportManager.handleException(DisabledDevSupportManager.java:170)
at com.facebook.react.bridge.CatalystInstanceImpl.onNativeException(CatalystInstanceImpl.java:525)
at com.facebook.react.bridge.CatalystInstanceImpl.access$1000(CatalystInstanceImpl.java:39)
at com.facebook.react.bridge.CatalystInstanceImpl$NativeExceptionHandler.handleException(CatalystInstanceImpl.java:541)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:193)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run(Thread.java:764)
Caused by: com.facebook.react.devsupport.JSException: Can't find variable: document (index.android.bundle:1632)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop(Looper.java:193) 
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192) 
at java.lang.Thread.run(Thread.java:764) 
Caused by: com.facebook.jni.CppException: Can't find variable: document (index.android.bundle:1632)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method) 
at android.os.Handler.handleCallback(Handler.java:873) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29) 
at android.os.Looper.loop(Looper.java:193) 
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192) 
at java.lang.Thread.run(Thread.java:764) 
APK worked OK after I restarted the RN upgrade process with react-native-git-upgrade. There was another issue after the upgrade with some unresolved symbol during runtime but that turned out to be an issue with the externs file because I had switched from the deprecated BackAndroid to BackHandler.

adb shell am start giving ClassNotFoundException

I am trying to launch an apk through adb command, soon after installing the apk but i am getting ClassNotFoundException and app is crashing.
My Log :
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.sample.test.one/com.sample.test.one.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.sample.test.one.MainActivity" on path: DexPathList[[zip file "/data/app/com.sample.test.one-1/base.apk"],nativeLibraryDirectories=[/data/app/com.sample.test.one-1/lib/arm, /system/lib, /vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2849)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6776)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1518)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sample.test.one.MainActivity" on path: DexPathList[[zip file "/data/app/com.sample.test.one-1/base.apk"],nativeLibraryDirectories=[/data/app/com.sample.test.one-1/lib/arm, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1086)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2839)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3045) 
at android.app.ActivityThread.-wrap14(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1642) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6776) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1518) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408) 
Flow :
adb install test.apk
adb shell am start -n com.sample.test.one/com.sample.test.one.MainActivity
or
adb shell am start -a android.intent.action.Main -n com.sample.test.one/.MainActivity
I am trying above adb shell commands but app is failing to launch but one scenario i have observed, if i will run the code in Android Studio and app gets installed in the device and after that if i will try "adb shell am start" command then it works fine but if i try through "adb install apk" then this command is not working.
I came across this situation once, but after adding MultiDex to my gradle , everything works great.
Step 1
defaultConfig {
minSdkVersion minVersion+
targetSdkVersion targetVersion+
multiDexEnabled true
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
Step 2
add gradle
compile 'com.android.support:multidex:1.0.0'
Step 3
Change gradle properties
org.gradle.jvmargs=-Xmx4096m
Please try this trick.
English is not my native language; please excuse typing errors.
Solution:
take a look in your App project file AndroidMainfest.xml , look for the activity contain this
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
in this scope ,remember this activity name property.
use this command
adb shell am start -D -n com.mycompany.moba.lala/com.epicgames.ue4.SplashActivity
replace the com.epicgames.ue4.SplashActivity with the previous name path.

Unable to instantiate application com.android.tools.fd.runtime.BootstrapApplication ?Android

I updated my Android Studio to version 2.0. But I had a problem, I don't know why?
The important error info:
Unable to instantiate application com.android.tools.fd.runtime.BootstrapApplication: java.lang.IllegalStateException: java.lang.ClassNotFoundException: com.eallcn.rentagent.MyDebugEallApplication
I searched a long time, But I didn't find the right answer
you can see the link
At the same time when I click File->Project structure
It shows this error:
Is there any problem somewhere in the libs? When gradle build the program the libs didn't load completely for current program. Is there any problem with Android Studio version 2.0?
When I use Android studio 1.4.0 to build and run the program. It works fine for me! But when I use the Android Studio 2.0, the problem shows up!
Why? Could you help me, please?
Here is detailed error log:
11-28 11:57:00.489 19890-19890/com.eallcn.rentagent.debug
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.eallcn.rentagent.debug, PID: 19890 java.lang.RuntimeException: Unable to instantiate application
com.android.tools.fd.runtime.BootstrapApplication:
java.lang.IllegalStateException: java.lang.ClassNotFoundException:
com.eallcn.rentagent.MyDebugEallApplication
at android.app.LoadedApk.makeApplication(LoadedApk.java:537) at
android.app.ActivityThread.handleBindApplication(ActivityThread.java:4586)
at android.app.ActivityThread.access$1800(ActivityThread.java:139)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5314)
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:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:680)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException:
java.lang.ClassNotFoundException:
com.eallcn.rentagent.MyDebugEallApplication
at
com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:167)
at
com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:179)
at android.app.Application.attach(Application.java:194)
at
android.app.Instrumentation.newApplication(Instrumentation.java:992)
at
android.app.Instrumentation.newApplication(Instrumentation.java:976)
at android.app.LoadedApk.makeApplication(LoadedApk.java:532)
at
android.app.ActivityThread.handleBindApplication(ActivityThread.java:4586) 
at android.app.ActivityThread.access$1800(ActivityThread.java:139) 
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5314) 
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:864) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:680) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.ClassNotFoundException:
com.eallcn.rentagent.MyDebugEallApplication
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:251)
at java.lang.Class.forName(Class.java:216)
at
com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:155)
at
com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:179) 
at android.app.Application.attach(Application.java:194) 
at
android.app.Instrumentation.newApplication(Instrumentation.java:992) 
at
android.app.Instrumentation.newApplication(Instrumentation.java:976) 
at android.app.LoadedApk.makeApplication(LoadedApk.java:532) 
at
android.app.ActivityThread.handleBindApplication(ActivityThread.java:4586) 
at android.app.ActivityThread.access$1800(ActivityThread.java:139) 
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5314) 
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:864) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:680) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.NoClassDefFoundError:
com/eallcn/rentagent/MyDebugEallApplication
at java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:251) 
at java.lang.Class.forName(Class.java:216) 
at
com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:155) 
at
com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:179) 
at android.app.Application.attach(Application.java:194) 
at
android.app.Instrumentation.newApplication(Instrumentation.java:992) 
at
android.app.Instrumentation.newApplication(Instrumentation.java:976) 
at android.app.LoadedApk.makeApplication(LoadedApk.java:532) 
at
android.app.ActivityThread.handleBindApplication(ActivityThread.java:4586) 
at android.app.ActivityThread.access$1800(ActivityThread.java:139) 
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5314) 
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:864) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:680) 
at dalvik.system.NativeStart.main(Native Method) 
Caused by: java.lang.ClassNotFoundException: Didn't find class
"com.eallcn.rentagent.MyDebugEallApplication" on path:
DexPathList[[zip file
"/data/app/com.eallcn.rentagent.debug-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.eallcn.rentagent.debug-1,
/vendor/lib, /system/lib, /data/datalib]]
at
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at java.lang.Class.classForName(Native Method) 
at java.lang.Class.forName(Class.java:251) 
at java.lang.Class.forName(Class.java:216) 
at
com.android.tools.fd.runtime.BootstrapApplication.createRealApplication(BootstrapApplication.java:155) 
at
com.android.tools.fd.runtime.BootstrapApplication.attachBaseContext(BootstrapApplication.java:179) 
at android.app.Application.attach(Application.java:194) 
at
android.app.Instrumentation.newApplication(Instrumentation.java:992) 
at
android.app.Instrumentation.newApplication(Instrumentation.java:976) 
at android.app.LoadedApk.makeApplication(LoadedApk.java:532) 
at
android.app.ActivityThread.handleBindApplication(ActivityThread.java:4586) 
at android.app.ActivityThread.access$1800(ActivityThread.java:139) 
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:136) 
at android.app.ActivityThread.main(ActivityThread.java:5314) 
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:864) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:680) 
at dalvik.system.NativeStart.main(Native Method)
 
Disable the Instant Run option in Android Studio. Instructions are in the Android Studio Instant Run documentation.
Instant Run tries to do hot swapping of your code; this causes the application class to be moved.
To disable Instant Run Go to File --> Settings--> Build,Execution,Deployment -->Instant Run ---> uncheck "Enable instant run"
I had the same error after trying to use the 2.0.
I solved it by reverting some gradle changes:
1/3:
Changing:
classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
By:
classpath 'com.android.tools.build:gradle:1.2.3'
2/3:
Changing:
buildToolsVersion '23.0.2'
By:
buildToolsVersion "21.1.2"
3/3: (in <project folder>/.idea/gradle.xml)
And:
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.8" />
By:
<option name="gradleHome" value="$APPLICATION_HOME_DIR$/gradle/gradle-2.4" />
I don't know what line is exactly the origin of the error, but with this three changes it was solved.
Hope that it helps you :)
I had the same error.
I solved it by cleaning the project ( Build > Clean Project )
Just go to Android Studio menu - Build --> Rebuild Project.
I was able to get rid of this error by updating gradle-wrapper.properties to gradle-2.14.1-all, and cleaning/rebuilding the project. Then it ran fine. No other changes were needed (as those suggested in the above answer)...
Changing to
classpath 'com.android.tools.build:gradle:2.0.0-alpha6'
fixed issue
I also got this error with Android 2.0 in stable channel.
What I did?
- I had an older version of the app already installed on the device (which was built using older version of the Studio) which I was trying to replace by running the newer app on device.
I just uninstalled the older version completely before running the new app and the trick worked.
Just for those who want to update classPath with latest gradle plugin version, Where to find latest plugin version?
Check in http://tools.android.com/tech-docs/new-build-system and update your classPath. Latest one at current is
classpath 'com.android.tools.build:gradle:2.0.0'.
Always try to build with latest plugin version.
If you don't want to disable Instant Run, just do a project clean and rerun.
Change classpath 'com.android.tools.build:gradle:2.1.2' to classpath 'com.android.tools.build:gradle:2.1.0' fixes my problem.
I also faced the same problem and i solved it. In my case it was due to a mistake in global class ( Throughout Application context class ) , my mistake was in AndroidManifest.xml i have declared the Application class VolleyHelper as :-
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true" android:name=".VolleyHelper"
android:theme="#style/AppTheme">
but in VolleyHelper.java i don't have a Default constructor . So i added default constructor in VolleyHelper.java ( Application Class ) .
you can also add this into your gradle to prevent making dex on debug
debug {
// dev utilizes minSDKVersion = 21 to allow the Android gradle plugin
// to pre-dex each module and produce an APK that can be tested on
// Android Lollipop without time consuming dex merging processes.
minSdkVersion 21
}
In some Android devices with versions before OS 5.0 we get the error message:
Caused by: java.lang.ClassNotFoundException: Didn't find class
"com.android.tools.fd.runtime.BootstrapApplication
We must disable "Instant Run".
Go to File > Settings > Built, Execution, Deployment > Instant Run
Then disable the option Enable Instant Run to hot swap code.
I just needed to reboot my device. Tried everything else first unfortunately so wasted hours.
If you are sharing your app then another solution is
go to Android Studio --> Build --> Build APK
A pop up will come with APK generated successfully. Show in Explorer will get you to the generated apk folder.
This error will happen when you add a blank activity with .java file. So to solve this error 1st you have to Build the project again. Then run it. Solved
Thank You.
No need to disable "instant run".
go to project's root using File Explorer
Finish Android Studio(AS)
delete(relocate somewhere) ".gradle" 's folder content
(to clean some cashs and old artifacts)
in res folder clean off all inappropriate files
launch the AS again
in module's build.gradle set buildTypes { debug {minifyEnabled true to false
(that looks like an error was in my proguard file)
Sync, compile and run the app again.
I just update Android Studio to the last version (2.0 Beta 5). It changes itself to classpath 'com.android.tools.build:gradle:2.0.0-beta5' and works like a charm.

Categories

Resources