I am working on an Android app which has Google Drive but even though it compiles fine it crashes when I try and do anything.
This is a pre-existing, it hasn't been worked on in and was originally an Eclipse project. Someone reported so imported into Android Studio and fixed the bug however when I try and do anything with Google Drive I get the following app crash.
Process: com.BoardiesITSolutions.PasswordManager, PID: 23121
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/common/base/Preconditions;
at com.google.api.client.googleapis.extensions.android.accounts.GoogleAccountManager.<init>(GoogleAccountManager.java:41)
at com.google.api.client.googleapis.extensions.android.accounts.GoogleAccountManager.<init>(GoogleAccountManager.java:48)
at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.<init>(GoogleAccountCredential.java:78)
at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.usingOAuth2(GoogleAccountCredential.java:97)
at com.BoardiesITSolutions.PasswordManager.Settings$SynchronisationSettings.enableGoogleDrive(Settings.java:575)
at com.BoardiesITSolutions.PasswordManager.Settings$SynchronisationSettings.access$000(Settings.java:420)
at com.BoardiesITSolutions.PasswordManager.Settings$SynchronisationSettings$1.onPreferenceChange(Settings.java:510)
at android.preference.Preference.callChangeListener(Preference.java:928)
at android.preference.ListPreference.onDialogClosed(ListPreference.java:281)
at android.preference.DialogPreference.onDismiss(DialogPreference.java:391)
at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1257)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.common.base.Preconditions" on path: DexPathList[[zip file "/data/app/com.BoardiesITSolutions.PasswordManager-1/base.apk"],nativeLibraryDirectories=[/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 com.google.api.client.googleapis.extensions.android.accounts.GoogleAccountManager.<init>(GoogleAccountManager.java:41)
at com.google.api.client.googleapis.extensions.android.accounts.GoogleAccountManager.<init>(GoogleAccountManager.java:48)
at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.<init>(GoogleAccountCredential.java:78)
at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.usingOAuth2(GoogleAccountCredential.java:97)
at com.BoardiesITSolutions.PasswordManager.Settings$SynchronisationSettings.enableGoogleDrive(Settings.java:575)
at com.BoardiesITSolutions.PasswordManager.Settings$SynchronisationSettings.access$000(Settings.java:420)
at com.BoardiesITSolutions.PasswordManager.Settings$SynchronisationSettings$1.onPreferenceChange(Settings.java:510)
at android.preference.Preference.callChangeListener(Preference.java:928)
at android.preference.ListPreference.onDialogClosed(ListPreference.java:281)
at android.preference.DialogPreference.onDismiss(DialogPreference.java:391)
at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1257)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5312)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
Suppressed: java.lang.ClassNotFoundException: com.google.common.base.Preconditions
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)
... 19 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
Below is the part of the code that crashes:
private void enableGoogleDrive()
{
credential = GoogleAccountCredential.usingOAuth2(context, DriveScopes.DRIVE);
startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER);
}
Its the credential = ... that is causing the crash.
Below is my build.gradle file
apply plugin: 'com.android.application'
android {
compileOptions.encoding = 'ISO-8859-1'
compileSdkVersion 21
buildToolsVersion "21.1.2"
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
defaultConfig {
applicationId "com.BoardiesITSolutions.PasswordManager"
minSdkVersion 14
targetSdkVersion 21
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_5
targetCompatibility JavaVersion.VERSION_1_5
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
repositories {
mavenLocal()
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile ('com.google.android.gms:play-services:7.0.0') {
exclude module: 'support-v4'
}
compile files('libs/commons-codec-1.4.jar');
compile files('libs/google-api-services-drive-v2-rev30-1.12.0-beta.jar')
compile ('com.android.support:appcompat-v7:21.0.0') {
exclude module: 'support-v4'
}
//compile 'com.android.support:support-v4:21.0.0'
compile ('com.BoardiesITSolutions:CritiMon:1.0') {
exclude module: 'support-v4'
}
compile ('com.BoardiesITSolutions:Library:1.1') {
exclude module: 'support-v4'
}
}
Update
I've found there is was a jar library I was missing. I've added this jar called google-collect-1.0.jar and rebuilt. When I run the above code it now works and I get a list of Google accounts that I select. However, when it then tries to do something with Drive I now get a different error.
FileList file = service.files().list().execute();
On the above line is what causes the crash. service is created by calling
credential.setSelectedAccountName(settings.getString("google_drive_account_name", ""));
Drive service = getDriveService(credential);
getDriveService is as follows:
private Drive getDriveService(GoogleAccountCredential credential)
{
return new Drive.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), credential).build();
}
The error I now get is:
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/common/primitives/UnsignedInteger;
at com.google.api.client.util.Data.<clinit>(Data.java:81)
at com.google.api.client.util.FieldInfo.<init>(FieldInfo.java:131)
at com.google.api.client.util.FieldInfo.of(FieldInfo.java:104)
at com.google.api.client.util.ClassInfo.<init>(ClassInfo.java:174)
at com.google.api.client.util.ClassInfo.of(ClassInfo.java:92)
at com.google.api.client.util.GenericData.<init>(GenericData.java:79)
at com.google.api.client.util.GenericData.<init>(GenericData.java:61)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.<init>(AbstractGoogleClientRequest.java:101)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.<init>(AbstractGoogleJsonClientRequest.java:57)
at com.google.api.services.drive.DriveRequest.<init>(DriveRequest.java:51)
at com.google.api.services.drive.Drive$Files$List.<init>(Drive.java:2914)
at com.google.api.services.drive.Drive$Files.list(Drive.java:2904)
at com.BoardiesITSolutions.PasswordManager.Classes.DriveSync$1.run(DriveSync.java:137)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.common.primitives.UnsignedInteger" on path: DexPathList[[zip file "/data/app/com.BoardiesITSolutions.PasswordManager-1/base.apk"],nativeLibraryDirectories=[/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 com.google.api.client.util.Data.<clinit>(Data.java:81)
at com.google.api.client.util.FieldInfo.<init>(FieldInfo.java:131)
at com.google.api.client.util.FieldInfo.of(FieldInfo.java:104)
at com.google.api.client.util.ClassInfo.<init>(ClassInfo.java:174)
at com.google.api.client.util.ClassInfo.of(ClassInfo.java:92)
at com.google.api.client.util.GenericData.<init>(GenericData.java:79)
at com.google.api.client.util.GenericData.<init>(GenericData.java:61)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.<init>(AbstractGoogleClientRequest.java:101)
at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.<init>(AbstractGoogleJsonClientRequest.java:57)
at com.google.api.services.drive.DriveRequest.<init>(DriveRequest.java:51)
at com.google.api.services.drive.Drive$Files$List.<init>(Drive.java:2914)
at com.google.api.services.drive.Drive$Files.list(Drive.java:2904)
at com.BoardiesITSolutions.PasswordManager.Classes.DriveSync$1.run(DriveSync.java:137)
at java.lang.Thread.run(Thread.java:818)
Suppressed: java.lang.ClassNotFoundException: com.google.common.primitives.UnsignedInteger
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)
... 15 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
Update 2
I think I have made some progress but I'm still getting a crash although different now.
Below is how my gradle file now looks
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
apply plugin: 'com.android.application'
android {
compileOptions.encoding = 'ISO-8859-1'
compileSdkVersion 21
buildToolsVersion "21.1.2"
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'README'
exclude 'com.google.api.client.json.JsonFactory.class'
//exclude 'GwtCompatible.class'
/*exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/LGPL2.1'
exclude 'META-INF/notice.txt'
exclude 'com.google.api.client.auth.oauth2.AuthorizationCodeFlow.class'
}
defaultConfig {
applicationId "com.BoardiesITSolutions.PasswordManager"
minSdkVersion 14
targetSdkVersion 21
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
repositories {
mavenLocal()
mavenCentral()
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.google.android.gms:play-services:7.0.0') {
exclude module: 'support-v4'
}
compile('com.google.http-client:google-http-client:1.18.0-rc') {
exclude group: 'xpp3'
exclude group: 'org.apache.httpcomponents'
exclude group: 'junit'
exclude group: 'com.google.android'
}
compile('com.google.http-client:google-http-client-jackson2:1.18.0-rc')
compile('com.android.support:appcompat-v7:21.0.0') {
exclude module: 'support-v4'
}
compile('com.BoardiesITSolutions:CritiMon:1.0') {
exclude module: 'support-v4'
}
compile('com.BoardiesITSolutions:Library:1.1') {
}
compile ('com.google.api-client:google-api-client-android:1.18.0-rc') {
}
compile ('com.google.http-client:google-http-client-gson:1.18.0-rc') {
}
}
Below is a screenshot of what my libs directory contains
The error that I am now getting is:
Process: com.BoardiesITSolutions.PasswordManager, PID: 25495
java.lang.NoSuchMethodError: No direct method <init>(Lcom/google/api/client/http/HttpTransport;Lcom/google/api/client/http/HttpRequestInitializer;Ljava/lang/String;Ljava/lang/String;Lcom/google/api/client/json/JsonObjectParser;Lcom/google/api/client/googleapis/services/GoogleClientRequestInitializer;Ljava/lang/String;Z)V in class Lcom/google/api/client/googleapis/services/json/AbstractGoogleJsonClient; or its super classes (declaration of 'com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient' appears in /data/app/com.BoardiesITSolutions.PasswordManager-2/base.apk)
at com.google.api.services.drive.Drive.<init>(Drive.java:135)
at com.google.api.services.drive.Drive$Builder.build(Drive.java:6542)
at com.BoardiesITSolutions.PasswordManager.Classes.DriveSync.getDriveService(DriveSync.java:365)
at com.BoardiesITSolutions.PasswordManager.Classes.DriveSync.access$000(DriveSync.java:65)
at com.BoardiesITSolutions.PasswordManager.Classes.DriveSync$1.run(DriveSync.java:134)
at java.lang.Thread.run(Thread.java:818)
I cannot see what is wrong with this at all, everything I try seems to result in the same problem. Everything compiles fine its just when the code executes it crashes.
The line that it crashes on now is below:
return new Drive.Builder(AndroidHttp.newCompatibleTransport(), new GsonFactory(), credential).build();
I have finally figured out a solution. Below is a screenshot of the libraries in my libs folder
Below is my gradle file
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
apply plugin: 'com.android.application'
android {
compileOptions.encoding = 'ISO-8859-1'
compileSdkVersion 21
buildToolsVersion "21.1.2"
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'com.google.gson.JsonSerializer'
exclude 'constant-values.html'
exclude 'overview-summary.html'
exclude 'package-list'
exclude 'overview-tree.html'
exclude 'allclasses-frame.html'
exclude 'allclasses-noframe.html'
exclude 'stylesheet.css'
exclude 'index-all.html'
exclude 'deprecated-list.html'
exclude 'index.html'
exclude 'overview-frame.html'
exclude 'help-doc.html'
}
defaultConfig {
applicationId "com.BoardiesITSolutions.PasswordManager"
minSdkVersion 14
targetSdkVersion 21
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
repositories {
mavenLocal()
mavenCentral()
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
dependencies {
compile ('com.google.android.gms:play-services-ads:7.0.0') {
exclude module: 'support-v4'
}
compile ('com.google.android.gms:play-services-drive:7.0.0') {
exclude module: 'support-v4'
}
compile fileTree(dir: 'libs', include: ['*.jar'])
compile('com.google.android.gms:play-services:7.0.0') {
exclude module: 'support-v4'
}
compile 'com.google.guava:guava:17.0'
compile('com.android.support:appcompat-v7:21.0.0') {
exclude module: 'support-v4'
}
compile('com.BoardiesITSolutions:CritiMon:1.0') {
exclude module: 'support-v4'
}
compile('com.BoardiesITSolutions:Library:1.1') {
}
}
Related
I have this strange error I do not know how to resolve. I test my App in my phone samsung j5 (Marshmellow) and it's working ok. But now i'm testing it in samsung j3 (lollipop) the app crash as startup and the error is this one:
10-02 22:28:59.426 4395-4395/com.example.sony.snapcamera E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.sony.snapcamera, PID: 4395
java.lang.RuntimeException: Unable to instantiate application com.example.sony.snapcamera.App: java.lang.ClassNotFoundException: Didn't find class "com.example.sony.snapcamera.App" on path: DexPathList[[zip file "/data/app/com.example.sony.snapcamera-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.sony.snapcamera-1/lib/arm, /vendor/lib, /system/lib]]
at android.app.LoadedApk.makeApplication(LoadedApk.java:661)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6002)
at android.app.ActivityThread.access$1700(ActivityThread.java:218)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6934)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.sony.snapcamera.App" on path: DexPathList[[zip file "/data/app/com.example.sony.snapcamera-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.sony.snapcamera-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.newApplication(Instrumentation.java:1003)
at android.app.LoadedApk.makeApplication(LoadedApk.java:651)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6002)
at android.app.ActivityThread.access$1700(ActivityThread.java:218)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1795)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6934)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Suppressed: java.lang.NoClassDefFoundError: com.example.sony.snapcamera.App
at dalvik.system.DexFile.defineClassNative(Native Method)
at dalvik.system.DexFile.defineClass(DexFile.java:226)
at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:219)
at dalvik.system.DexPathList.findClass(DexPathList.java:321)
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)
... 14 more
Suppressed: java.lang.ClassNotFoundException: com.example.sony.snapcamera.App
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)
... 13 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
This is my AndroidManifest :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sony.snapcamera">
.....
<application
android:name="com.example.sony.snapcamera.App"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="#mipmap/App_icon"
android:label="#string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:theme="#style/AppTheme"
>
...
This is my App class :
package com.example.sony.snapcamera;
import android.app.Application;
import android.content.Context;
import com.adobe.creativesdk.foundation.AdobeCSDKFoundation;
import com.adobe.creativesdk.foundation.auth.IAdobeAuthClientCredentials;
import com.bumptech.glide.request.target.ViewTarget;
public class App extends Application implements IAdobeAuthClientCredentials {
/* Be sure to fill in the two strings below. */
private static final String CREATIVE_SDK_CLIENT_ID = "";
private static final String CREATIVE_SDK_CLIENT_SECRET = "";
private static final String CREATIVE_SDK_REDIRECT_URI = "";
private static final String[] CREATIVE_SDK_SCOPES = {"email", "profile", "address"};
#Override
public void onCreate() {
super.onCreate();
ViewTarget.setTagId(R.id.glide_tag);
AdobeCSDKFoundation.initializeCSDKFoundation(getApplicationContext());
}
#Override
public String getClientID() {
return CREATIVE_SDK_CLIENT_ID;
}
#Override
public String getClientSecret() {
return CREATIVE_SDK_CLIENT_SECRET;
}
#Override
public String[] getAdditionalScopesList() {
return CREATIVE_SDK_SCOPES;
}
#Override
public String getRedirectURI() {
return CREATIVE_SDK_REDIRECT_URI;
}
}
Here it is my app gradle :
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1'
}
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example.sony.snapcamera"
minSdkVersion 21
targetSdkVersion 25
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [appPackageName: "${applicationId}"]
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/DEPENDENCIES'
pickFirst 'AndroidManifest.xml'
}
dexOptions {
jumboMode true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.makeramen:roundedimageview:2.2.1'
compile 'com.github.XunMengWinter:CircularAnim:0.3.4'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.zomato:androidphotofilters:1.0.1'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.android.support:design:25.3.1'
compile 'com.github.chrisbanes:PhotoView:1.3.1'
compile 'com.writingminds:FFmpegAndroid:0.3.2'
compile 'com.google.firebase:firebase-database:11.4.0'
compile 'com.google.android.gms:play-services:11.4.0'
compile 'com.google.maps.android:android-maps-utils:0.4.3'
compile 'com.firebaseui:firebase-ui:0.4.0'
compile 'com.google.firebase:firebase-auth:11.4.0'
compile 'com.google.firebase:firebase-crash:11.4.0'
compile 'com.google.code.gson:gson:2.8.1'
// compile 'com.firebase:geofire-android:2.1.1'
compile 'com.algolia:algoliasearch-android:3.10.1'
// compile 'com.android.support:cardview-v7:25.1.1'
/* Add the CSDK framework dependencies (Make sure these version numbers are correct) */
compile 'com.adobe.creativesdk.foundation:auth:0.9.1251'
compile 'com.adobe.creativesdk:image:4.8.4'
compile 'com.localytics.android:library:3.8.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
I already tested to clean and rebuild project, I also tested to disable instant run but nothing worked for me, I can't even realise the problem because it works very good in j5 and it crash in j3, Please help.
enable multidex,
1. Add following dependency in app gradle file compile
'com.android.support:multidex:1.0.1' and
defaultConfig {
multiDexEnabled true
}
2. Your application class need to extends MultiDexApplication
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
...
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
compile 'com.google.firebase:firebase-core:10.2.0'
})
compile 'com.android.support:appcompat-v7:25.3.1'
...
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-games:10.2.0'
compile 'com.google.android.gms:play-services-plus:10.2.0'
}
apply plugin: 'com.google.gms.google-services'
Logcat:
08-06 14:07:01.005 8404-8648/com.metabrain.emre E/GooglePlayServicesUtil: The Google Play services resources were not
found. Check your project configuration to ensure that the resources
are included.
08-06 14:07:01.795 8404-8690/com.metabrain.emre E/libEGL: validate_display:255 error 3008 (EGL_BAD_DISPLAY)
08-06 14:07:06.246 8404-8404/com.metabrain.emre E/UncaughtException: java.lang.RuntimeException: Failure delivering
result ResultInfo{who=null, request=9001, result=10002, data=Intent {
(has extras) }} to activity
{com.metabrain.emre/com.metabrain.emre.Main_Activity}:
java.lang.NullPointerException: Attempt to invoke virtual method 'void
android.app.Dialog.show()' on a null object reference
at android.app.ActivityThread.deliverResults(ActivityThread.java:3636)
at
android.app.ActivityThread.handleSendResult(ActivityThread.java:3679)
at android.app.ActivityThread.access$1300(ActivityThread.java:151)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1358)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5354)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual
method 'void android.app.Dialog.show()' on a null object reference
at
com.google.example.games.basegameutils.GameHelper.showFailureDialog(GameHelper.java:950)
at
com.google.example.games.basegameutils.GameHelper.showFailureDialog(GameHelper.java:931)
at
com.google.example.games.basegameutils.GameHelper.giveUp(GameHelper.java:909)
at
com.google.example.games.basegameutils.GameHelper.onActivityResult(GameHelper.java:615)
at
com.google.example.games.basegameutils.BaseGameActivity.onActivityResult(BaseGameActivity.java:123)
at android.app.Activity.dispatchActivityResult(Activity.java:6223)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3632)
at
android.app.ActivityThread.handleSendResult(ActivityThread.java:3679)
at android.app.ActivityThread.access$1300(ActivityThread.java:151)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1358)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5354)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
08-06 14:07:06.539 8404-8404/com.metabrain.emre E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.metabrain.emre, PID: 8404
java.lang.RuntimeException: Failure delivering result
ResultInfo{who=null, request=9001, result=10002, data=Intent { (has
extras) }} to activity
{com.metabrain.emre/com.metabrain.emre.Main_Activity}:
java.lang.NullPointerException: Attempt to invoke virtual method 'void
android.app.Dialog.show()' on a null object reference
at android.app.ActivityThread.deliverResults(ActivityThread.java:3636)
at
android.app.ActivityThread.handleSendResult(ActivityThread.java:3679)
at android.app.ActivityThread.access$1300(ActivityThread.java:151)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1358)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5354)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual
method 'void android.app.Dialog.show()' on a null object reference
at
com.google.example.games.basegameutils.GameHelper.showFailureDialog(GameHelper.java:950)
at
com.google.example.games.basegameutils.GameHelper.showFailureDialog(GameHelper.java:931)
at
com.google.example.games.basegameutils.GameHelper.giveUp(GameHelper.java:909)
at
com.google.example.games.basegameutils.GameHelper.onActivityResult(GameHelper.java:615)
at
com.google.example.games.basegameutils.BaseGameActivity.onActivityResult(BaseGameActivity.java:123)
at android.app.Activity.dispatchActivityResult(Activity.java:6223)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3632)
at
android.app.ActivityThread.handleSendResult(ActivityThread.java:3679)
at android.app.ActivityThread.access$1300(ActivityThread.java:151)
at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1358)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5354)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)
Normally this happens with emulator , so this message could be ignored if you included google play service correctly.
There's giving me following error in my demo app:
FATAL EXCEPTION: main
Process: com.example.android.pos_api_android_demo, PID: 9359
java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app-lib/com.example.android.pos_api_android_demo-13/libPosAPI.so" not 32-bit: 2
at java.lang.Runtime.loadLibrary(Runtime.java:365)
at java.lang.System.loadLibrary(System.java:526)
at com.vatps.android.PosAPI.<clinit>(PosAPI.java:35)
at com.example.android.pos_api_android_demo.MainActivity$1.onClick(MainActivity.java:23)
at android.view.View.performClick(View.java:4867)
at android.view.View$PerformClick.run(View.java:19722)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5756)
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:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
Yes , libPosAPI.so file is 64 bit. There are solution like this. [https://bugs.chromium.org/p/webrtc/issues/detail?id=4186][1]
[1]: https://bugs.chromium.org/p/webrtc/issues/detail?id=4186 But this is for linux user. I'm using Windows. and old topic is all about error:32 bit instead 64.
My Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.example.android.pos_api_android_demo"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets.main {
jniLibs.srcDirs = ['libs']
jni.srcDirs = [] //disable automatic ndk-build call with auto-generated Android.mk file }
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
testCompile 'junit:junit:4.12'
}
Project Gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.myapp"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE-FIREBASE.txt'
exclude 'META-INF/NOTICE'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.android.support:support-v4:24.2.1'
//compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.google.android.gms:play-services:9.8.0'
compile 'com.google.firebase:firebase-core:9.8.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Activity:
private DatabaseReference mDatabase;
...
mDatabase = FirebaseDatabase.getInstance().getReference(Config.FIREBASE_URL); //public static final String FIREBASE_URL = "https://myapp.firebaseio.com/ ";
...
mDatabase.setValue(edittextName.getText().toString());
Class:
public class Config {
public static final String FIREBASE_URL = "https://myapps.firebaseio.com/ ";
}
I am getting the following error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.myapp, PID: 30211
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/com.myapp.MainActivity}: com.google.firebase.database.DatabaseException: Failed to get FirebaseDatabase instance: FirebaseApp object has no DatabaseURL in its FirebaseOptions object.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2316)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2376)
at android.app.ActivityThread.access$800(ActivityThread.java:147)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5253)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: com.google.firebase.database.DatabaseException: Failed to get FirebaseDatabase instance: FirebaseApp object has no DatabaseURL in its FirebaseOptions object.
at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
at com.google.firebase.database.FirebaseDatabase.getInstance(Unknown Source)
at com.myapp.MainActivity.onCreate(MainActivity.java:103)
at android.app.Activity.performCreate(Activity.java:5975)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2376)
at android.app.ActivityThread.access$800(ActivityThread.java:147)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1281)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5253)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
How can I resolve the issue.
The link provided does not resolve my issue!
Per #qbix, I had to use getReferenceFromUrl() and the app didn't crash.
I'm attempting to get Robolectric 2.4 working with my Cordova Project in Android Studio 1.0.2 and when I run the test ./gradlew clean test I get the following exception:
java.lang.ClassCastException: java.lang.ExceptionInInitializerError cannot be cast to java.lang.RuntimeException
at org.robolectric.internal.ReflectionHelpers.callInstanceMethodReflectively(ReflectionHelpers.java:68)
at org.robolectric.util.ActivityController$1.run(ActivityController.java:115)
at org.robolectric.shadows.ShadowLooper.runPaused(ShadowLooper.java:268)
at org.robolectric.util.ActivityController.create(ActivityController.java:111)
at org.robolectric.util.ActivityController.create(ActivityController.java:122)
at de.dfki.telcoPortal.example.DeckardActivityRobolectricTest.setup(DeckardActivityRobolectricTest.java:30)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:236)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:158)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:69)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:360)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
I have tried different solutions but not luck. I don't know what I made wrong. Could anyone help me with this error?
My top-level build.gradle looks like:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0+'
classpath 'org.robolectric:robolectric-gradle-plugin:0.14.+'
}
}
allprojects {
repositories {
mavenCentral()
}
}
apply plugin: 'com.android.application'
apply plugin: 'robolectric'
android {
packagingOptions {
exclude 'LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE'
}
compileSdkVersion 19
buildToolsVersion '21.1.2'
sourceSets {
main {
manifest.srcFile './src/main/AndroidManifest.xml'
res.srcDirs = ['./src/main/res']
assets.srcDirs = ['assets']
}
androidTest {
setRoot('src/test')
}
}
defaultConfig {
testInstrumentationRunner "com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunner"
}
lintOptions {
abortOnError false
}
productFlavors {
}
buildTypes {
}
}
robolectric {
include '**/*Test.class'
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':CordovaLib')
compile 'com.android.support:support-v13:19.1.0'
androidTestCompile('junit:junit:4.12') {
exclude module: 'hamcrest-core'
}
androidTestCompile('org.robolectric:robolectric:2.4') {
exclude module: 'classworlds'
exclude module: 'commons-logging'
exclude module: 'httpclient'
exclude module: 'maven-artifact'
exclude module: 'maven-artifact-manager'
exclude module: 'maven-error-diagnostics'
exclude module: 'maven-model'
exclude module: 'maven-project'
exclude module: 'maven-settings'
exclude module: 'plexus-container-default'
exclude module: 'plexus-interpolation'
exclude module: 'ple`enter code here`xus-utils'
exclude module: 'wagon-file'
exclude module: 'wagon-http-lightweight'
exclude module: 'wagon-provider-api'
}
}
apply plugin: 'idea'
idea {
module {
testOutputDir = file('build/test-classes/debug')
}
}
My Activity is:
public class CordovaApp extends CordovaActivity
{
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.init();
// Set by <content src="index.html" /> in config.xml
loadUrl(launchUrl);
}
}
and my basic Test is
#Config(manifest = "./src/main/AndroidManifest.xml", emulateSdk = 18)
#RunWith(RobolectricTestRunner.class)
public class CordovaAppTest{
private CordovaApp activity;
#Test
public void testSomething() throws Exception {
activity = Robolectric.buildActivity(CordovaApp.class)
.create().get();
assertTrue(activity != null);
}
}