"The following classes could not be instantiated " Whenever i add a library - java

i'm trying to add some library in my application like me.itangqi.waveloadingview.WaveLoadingView from : Github The first time works well but after first RUN I have this error :
The following classes could not be instantiated:
- me.itangqi.waveloadingview.WaveLoadingView (Open Class, Show Exception, Clear Cache)
I already tried Clean/Rebuild but still the same ( doesn't work ).
My build.Gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "maa.maxbattery_batterypowersave"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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.0'
compile 'com.android.support:design:25.3.0'
compile 'me.itangqi.waveloadingview:library:0.3.5'
testCompile 'junit:junit:4.12'
}
My Style.xml :
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#262626</item>
<item name="colorPrimaryDark">#262626</item>
<item name="colorAccent">#262626</item>
</style>

Related

How to access dependencies of dependencies with gradle in android studio?

Am I missing something here? I'm using android studio. I will be developing two apps with a shared code base, so I made three modules in my android studio project. One module is a library project with shared code, and the other two are apps. This is an app build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "omitted"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation project(':lib')
implementation fileTree(dir: 'libs', include: ['*.jar'])
}
this is the shared module's build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
My expectation is that my app should have access to the dependencies of the shared code module (for example 'com.android.support:appcompat-v7:26.1.0'). Is this wrong? I cannot find any way to pass on these dependencies to the dependent app.
The answer is to use api instead of implementation in my shared module's 'build.gradle dependencies.
ie. I want api 'com.android.support:appcompat-v7:26.1.0' instead of implementation 'com.android.support:appcompat-v7:26.1.0'
Courtesey of Jaydip Kalani's comment and How do I share dependencies between Android modules
However as far as I'm aware there is no such thing as testApi to replace testImplementation.

Problem authenticating with gmail on Android

Cannot authenticate with Google on Android. Android Studio shows these errors:
The following classes could not be instantiated:
com.google.android.gms.common.SignInButton
Here is my XML
<com.google.android.gms.common.SignInButton
android:id="#+id/sign_in_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
and here is my app gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.ramadanapp.android.firebaseuploadimage"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.google.firebase:firebase-storage:11.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.firebase:firebase-auth:11.4.0'
compile 'com.google.android.gms:play-services-auth:11.4.0'
}
apply plugin: 'com.google.gms.google-services'
Have you added dependency in build.gradle file at project level? If not then add the below dependency in that.
dependencies{
classpath 'com.google.gms:google-services:3.0.0'
...
}
i think you didn't add the dependencies of play-services-auth
Just add compile 'com.google.android.gms:play-services-auth:11.4.0' dependencies in build.gradle app file like below code
dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.google.android.gms:play-services-auth:11.4.0'
}

How to compile module package in build gradle?

I'am trying to compile a package folder in build.gradle in android studio .and when I sync error show "Error:(29, 0) Supplied String module notation 'com.google.activities.components.runtime.ListPickerActivity' is invalid. Example notations: 'org.gradle:gradle-core:2.2', 'org.mockito:mockito-core:1.9.5:javadoc'.
build gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "store.muha.com.freequranapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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:23.4.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.activities.components.runtime.ListPickerActivity'
testCompile 'junit:junit:4.12'
}
any suggestions ?

APK build fails when compiling with 'net.lingala.zip4j:zip4j:1.3.2'

Getting the following error when trying to build the APK.
Error:Execution failed for task
':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
net/lingala/zip4j/core/HeaderReader.class
My gradle looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "24.0.2"
defaultConfig {
multiDexEnabled true
applicationId "com.test.myapp"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
}
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.android.support:appcompat-v7:25.0.0'
testCompile 'junit:junit:4.12'
compile 'net.lingala.zip4j:zip4j:1.3.2'
compile 'eu.chainfire:libsuperuser:1.0.0.+'
compile 'com.android.support:multidex:1.0.0'
}
I created a new project in Android Studio and simply copied all of the old files, except for the gradel. It now it works fine to build the APK file. Unfortunately this doesn't really explain why the problem emerged in first place. I have included a copy of the new gradle file below but the only main differences is the support for “mulitdex” which didn't really make any difference if I removed from the first version of the gradle file.
But now it finally works so I am happy with that.
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.1"
defaultConfig {
applicationId "com.test.myapp"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
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.1.0'
compile group: 'net.lingala.zip4j', name: 'zip4j', version: '1.3.2'
testCompile 'junit:junit:4.12'
}

junit error when creating a new project in android studio

when i create new project on android studio i receive error :
and this is the code when i click on show in project :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "org.ashiyane.sepehr"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
}
Just comment that line in build.gradle file..
//testCompile 'junit:junit:4.12'
Check your module Dependencies :
Android Studio > File > Project Structure > Select your Module >Dependencies > + > Library Dependency > check it available or not otherwise update your repository in SDK

Categories