I just installed Android Studio and whenever I start a project (even the default "Hello world" activity created by the IDE).
I have this exception which is raised :
java.lang.ClassNotFoundException: Didn't find class
"android.widget.ViewStub" on path: DexPathList[[zip file
"/data/app/com.example.noname.exceptiontest-2/base.apk"],nativeLibraryDirectories=[/vendor/lib
/system/lib]]
I wished I had some logcat to show but it doesn't seems like this exception is logged in it.
It doesn't stop the project or any other project that I have from working, just a little bit frustrating to go through the stack of this exception every time I run my projects in debug.
After looking around the Internet it doesn't seem that that many people have this problem, only answer that would match my issue would be a problem with Android studio. However those answers dated from more than one year.
I just changed my computer and wanted to move from Eclipse to Android Studio to do some development on my free time. I don't have access to my previous environment for the moment to try to install Android studio and reproduce that error.
Does anyone have or already had this error ? (To reproduce New Hello world Activity, activate any exception in Android Studio and run in debug)
Cheers
If you are getting this exception because you have set exception breakpoint, then instead of debugging, remove all breakpoints, just run the code,go to logcat and check the logs for the actual exception.
You could be trying to access a nested component like button from the grandparent and therefore the error.
ViewStub lays in a package called android.view, not android.widget. Change the import directive and see if it helps.
Old question, but I had this same issue with Android Studio 2.3
With a project that had 4 modules, the trouble was that I had a misspelling in one of the gradle.build files for one of the modules in the applicationId value.
defaultConfig {
applicationId "com.my.project"
}
After fixing this, and verifying all of the AndroidManifest.xml values for package matched the build.gradle value above within each module, it worked.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.my.project">
</manifest>
You may also need to go to File > Invalidate Caches / Restart... to clean it all out.
the method findClass(String name) of the classLoader that defined by yourself don't throws ClassNotFoundException.
Related
In other news, I spent half a day - being a beginner and all - trying to import DeskClock into Android Studio, so I could study it better, instead of crawling dozens of source code files.
Cloning the project didn't work out, what with missing gradle files, and Android Studio not recognising it as an Android app, therefore not loading necessary configurations that'd enable one to run it.
Next line of action was to try creating an Android project, deleting MainActivity.java & activity_main.xml; copying over files from DeskClock (com.android.deskclock), making necessary refactoring to avoid provider & package name conflicts. Did so and upon running the app, I got errors here and there, related to missing dependencies, which I added and tried running again; app installs, but keeps crashing due to errors I attribute to multiDex being disabled; I enabled it (via build.gradle, by setting multiDexEnabled to true, extending MultiDexApplication in DesktopClockApplication instead of Application), but still face the error::
E/hengnet.decloc: [qarth_debug:] get PatchStore::createDisableExceptionQarthFile method fail.
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.blogspot.thengnet.declock, PID: 22671
java.lang.RuntimeException: Unable to instantiate application com.blogspot.thengnet.declock.deskclock.DeskClockApplication: java.lang.ClassNotFoundException: Didn't find class "com.blogspot.thengnet.declock.deskclock.DeskClockApplication" on path: DexPathList[[zip file "/data/app/com.blogspot.thengnet.declock-rXBKN9OfqNprzSTBu6qqMg==/base.apk"],nativeLibraryDirectories=[/data/app/com.blogspot.thengnet.declock-rXBKN9OfqNprzSTBu6qqMg==/lib/arm64, /system/lib64, /product/lib64]]
What is the way IN?
What do I need to set up to get Google's open source apps running?!
Inspiration: How to import an Android Studio project from android.googlesource.com?
My purpose it to build a decent scheduling app for Alarm & Calendar, so anything besides would play out anyway. Thanks!
I am trying to compile my android app that I am crating by following the google tutorial at https://developer.android.com/training/index.html
I have run into a problem where I get the error "R cannot be resolved to a variable"
I followed the suggestions from the other threads such as cleaning/rebuiding, removing all import android.R, and reinstalling my Android SDK Build-tools for every version
Here is a copy of the tutorial project with the issue MyFirstApp.zip
I have taken the suggestions found in other threads, but their solutions have been unsuccessful.1 2 3 4 Please help!
Please let me know if there is any other information you need to fix this issue.
I have seen your code there is an error inside main_activity_actions.xml which is inside your menu folder
It does not find #string/action_search which must be present in strings.xml
So put <string name="action_search">Search here</string> inside your strings.xml
and clean and build the project.
I hope the error will be solved.
It usually append when you have an error with your XML file.
Maybe you try to use an XML variable who doesn't exist anymore. It will not give you any error on your XML.
Verify your XML variable on your file 'Value' and which you call from your Java file
Seriously, i don't know what to do to solve this problem.
My android project was working fine, until i needed to import a library with Maven. Since that, everything started to collapse.
What is happening: When i start my application, the following error appears on LogCat and android tells that my app stopped working. I've searched for this similar error here AND on the rest of the internet, but everything people did haven't worked for me.
Error:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.buscaserra/com.buscaserra.main.ActivitySplash}: java.lang.ClassNotFoundException: Didn't find class "com.buscaserra.main.ActivitySplash" on path: DexPathList[[zip file "/system/framework/com.google.android.maps.jar", zip file "/data/app/com.example.buscaserra-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.buscaserra-2, /vendor/lib, /system/lib]]
Manifest and packages:
Build Path:
Same problem here.
What worked for me was adding android-support-v4.jar as a lib and making sure it was checked on Project properties -> Build Path -> Order & export.
It was mentioned here
I had the same problem when I moved the project folder from a Linux machine to a Mac.
What I did was:
Close the project
Remove the .iml file
Import the project using the "Create new project using existing code"
I am using IntelliJ.
Cheers.
I did the following steps to resolve the issue on Android Studio.
open file ./app/build.gradle
reduce compileSdkVersion (e.g. 22 -> 21)
click 'sync project with gradle file'
change back to the original compileSdkVersion (e.g. 22)
click 'sync project with gradle file'
recompile and it should work.
I have spent way to many hours on this stupid issue but finally got it resolved:
When creating a new project -> package name is causing this stupid dex issue to appear, must not be able to find the main activity during run time with whatever deployment assemply setup. Android Studio doesn't like some of my commonly used package names, I'm completely baffled..I think this is a pretty big bug haha
Given the following new project parameters:
Name: NotificationApp,
packageName: com.stores.business.notificationapp,
saveLocation: /home/me/AndroidStudioProjects/NotificationApp
I would get the following error:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.stores.business.notificationapp/com.stores.business.notificationapp.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.stores.business.notificationapp.MainActivity" on path: DexPathList[[zip file "/data/app/com.stores.business.notificationapp-2/base.apk"],nativeLibraryDirectories=[/data/app/com.cvs.stores.myapplication-2/lib/arm64, /vendor/lib64, /system/lib64]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2327)
My Solution
I resolved it by changing the package name to:com.notificationapp, then File->invalidate caches/Restart..hope this helps someone else haha
Do you have any required projects on the build path? Can't tell from your screen shot but check your "Projects" tab. You may have inadvertently added a Project Library as a required project instead. Remove the project from the Projects tab and then project -> properties. Click Android, add the project as a library instead here...
Make sure that any compatibility lib jars that you're using in your main project (like android-support-v4.jar) are the same versions as those used in any of the projects that your main project references.
I had this same problem and what solved it was to copy and paste the android-support-v4.jar from another library project (that my main project was referencing) and pasting it into my main project's /libs folder.
I had the same issue.
Nothing had changed except Android studio and Gradle updated since I last compiled.
I took a look at the build options under Build>Edit Build Types and noticed that the one option that was different between my project that didn't run and the ones that did work was the Minify Enable option.
I set it to false and now everything works again.
I should understand the problem by just seeing "dex errors".But it took half day to fix the issue.
I fix this by following android developers page's instruction: https://developer.android.com/studio/build/multidex.html
First add this to my gradle.build:
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
}
Then I extend my Application class (or declare the application class in AndroidManifest.xml or override attachBaseContext() function) as instructed by the MultiDexApplication class document on the page. This have fixed my problem.
Receiving the following message when uploading my latest APK:
You need to use a different version code for your APK because you already have one with version code 1.
I am setting the android:versionCode and android:versionName correctly (in /app/src/main/AndroidManifest.xml):
android:versionCode="2"
android:versionName="1.1"
Also, I am using the same keystore that the project was initialized / originally built with
This is my 5th app and I've never encountered this issue before.
Is there some other place within a typical Android app project that could override the versionCode found in the AndroidManifest.xml file? Or maybe some kind of "de-linter" tool that'll help?
The path names suggest you're using Android Studio. Android Studio is using the Gradle build system. Possibly the build.gradle files specify version name/code that override whatever you set in manifest. So, to change it, edit your build.gradle file(s) and check for overridden versionCode / versionName.
Clean your app. Then save all files and then build
I am currently developing an Android app using cordova 2.0. Obviously the plugins.xml has been depreciated and everything is now housed in config.xml. I was just wondering if anyone has managed to get the Phonegap Screenshot plugin working in Eclipse and Cordova 2.0 working on android.
Plugin can be found:
https://github.com/josemando/phonegap-plugins/tree/master/Android/Screenshot
I have added:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
to my Android manifest xml. And made sure that:
<plugin name="Screenshot" value="org.apache.cordova.Screenshot"/>
is added to my config.xml (that now contains all plugin information from plugin.xml)
Screenshot.js is added to the directory:
assets/www/js/
However I am unsure where exactly to place the Screenshot.java file. The example has it in:
src / org / apache / cordova /
However as I did not have this directory I simply placed it in:
src/uk.co..appname1.appname2/
When I did this however it produced errors, the first one being:
The declared package "org.apache.cordova" does not match the expected package "uk.co.mysitename.appname1.appname2" Screenshot.java /Project Name/src/uk/co/mysitename/appname1/appname2line 8 Java Problem
This refers to this line in the Screenshot.js:
package org.apache.cordova;
The two suggested actions to fix this are to:
Move 'Screenshot.java' to package 'org.apache.cordova' (this directory doesn't exsist atm)
Or change package directory to 'uk.co.mysitename.appname1.appname2'
The second error says:
The method run() of type new Runnable(){} must override a superclass method
The suggested action for this being to "remove '#override' annotation"
I have tried to do every possible combination of these however I cannot seem to make progress and get it all to link up. Usually because it thinks that CordovaRef isn't referenced. I am unsure if the plugin even works on Cordova 2.0.0. I have some experience with Phonegap/Cordova but only in ios with Xcode and Objective C plugins. I am new to Java, Eclipse and Android. Any help or clarification on any of these matters would be greatly appreciated.
Answer resolved by:
Phonegap Screenshot plugin in Cordova 2.0.0
Answer/solution provided by Simon MacDonald