Stripe Android, Cannot resolve symbol 'PaymentConfiguration' - android

I'm trying to add a Payment Method in Stripe. In the client side (android) I'm adding the dependency implementation 'com.stripe:stripe-android:19.1.0'
The gradle version looks like
dependencies {
...
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.android.tools.build:gradle:4.0.2'
}
And my gradle app file version looks like
apply plugin: 'com.android.application'
android {
compileSdkVersion 31
defaultConfig {
applicationId "com.buscaride.dev"
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dataBinding{
enabled=true
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
...
implementation 'androidx.appcompat:appcompat:1.4.0'
...
implementation 'com.stripe:stripe-android:19.1.0'
}
So, when I try to import com.stripe.android.PaymentConfiguration; it says:
Cannot resolve symbol 'PaymentConfiguration'
No clue what I'm missing

Worked for me when I upgraded Android Studio to latest version.

Did you tried to invalidate Caches in "File Menu -> Invalidate Caches / Restart"?

Related

Error: Invoke-customs are only supported starting with Android O (--min-api 26)

I have recently started learning how to program Android devices via Android Studio. My first app was running fine until I upgraded to Android Studio 3.4 this morning.
I'm getting the following compilation errors:
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Failed to process C:\Users\Technical.gradle\caches\transforms-2\files-2.1\4f3f8638c6a9f961dae488a0387efb6b\jars\classes.jar
Caused by: com.android.builder.dexing.DexArchiveBuilderException: Error while dexing.
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Caused by: com.android.tools.r8.utils.AbortException: Error: Invoke-customs are only supported starting with Android O (--min-api 26)
Is there a way of reverting back to my previous version of Android Studio?
If not what has changed in the new version that is causing a failure in creating the dex file?
I have tried adding android.enableD8=true in gradle.properties as suggested here but no luck.
EDIT #1:
Have also tied adding multiDexEnabled true to the default configuration in the app build.gradle file but the same compilation errors persist.
That build file in full...
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "qdivision.org.qrtracker"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
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:28.0.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'
implementation 'com.github.felHR85:UsbSerial:6.0.5'
}
Try to add below to your app/build.gradle to make your Android project compilation be compatible with Java 8.
android {
....
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
....
}
I had to remove useProguard true from the buildTypes configuration.
According to the documentation minifyEnabled true is enough to obfuscate your code with R8.
Example:
android {
buildTypes {
debug {
versionNameSuffix "-dev"
minifyEnabled true // <- remove this line when using instant run
useProguard true // <- remove this line
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), "proguard-rules.pro"
}
release {
shrinkResources true
minifyEnabled true
useProguard true // <- remove this line
signingConfig signingConfigs.release
proguardFiles getDefaultProguardFile('proguard-android.txt'), "proguard-rules.pro"
}
}
}
for me following command in BUILD.GRADLE removed the error.
defaultConfig {
applicationId "com.example.myapptestheader"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
I just added
multiDexEnabled true
What is relevant in this stacktrace is this line:
Caused by: com.android.tools.r8.utils.AbortException: Error: Invoke-customs are only supported starting with Android O (--min-api 26)
As there is not kotlin library in your dependencies, I assume you’re working with java. I would try answers in this issue
in your Android Studio go to build.gradle(Module:App)
then add this compileOptions{} block into android{} block
android{
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
If you are using Google Cloud library, try to decrease the version to 1.90
Add the following to make your app to be compiled by java8 compiler.
android {
.....
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
And disable instant-run found at
Preferences->Build,Execution,Deployment->Debugger->Instant Run
I have added to all modules these code:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
But error was still there.
In my case some of my modules used classpath 'me.tatarka:gradle-retrolambda' and it gave the conflict with this:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
So I have to migtrated from Retrolambda by this link:
https://developer.android.com/studio/write/java8-support#migrate_from_retrolambda
Please add this line in build.gradle file.
android{
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
I had the same problem. Mine was caused by ... org.apache.commons:commons-lang .... I do not have the complete error message at the moment. This error only occurred during a Rebuild or Clean Build.
I Resolved by changing the org.apache.commons:commons-text:1.8 in my build.gradle to org.apache.commons:commons-text:1.6.
Note - There was a suggestion here to disable "Instant Run" in Android Studio. This feature was not available in my Android Studio. Version -
Android Studio 3.5.1
Build #AI-191.8026.42.35.5900203, built on September 26, 2019
Windows 10 10.0
for kotlin you should also add kotlinOptions:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
for me solution with Java 8 started work only after I have removed all ting related to retrolambda.
For anyone else hitting this, I encountered this problem after adding a dependency on this Jackson library:
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.11.1")
The "compileOptions" solution above fixed the issue for me
This still works in 2021 please try it.
android {
compileSdkVersion 30
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.example.android.bakingapp"
minSdkVersion 15
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
For my case, It was also showing after adding the following lines -
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
So I fixed my problem just simply update my minSdkVersion from 19 to 21 and then finally it worked !!!
I faced this error after upgrading the core libraries in build.gradle to there latest versions luckily accepted answer worked for me.
The reason of working of accepted answer was the change in the latest version of core library targeting api level 30 which is written in java8 therefore adding dependency to java8 solved it.
As of December 2021, this is what works.
The reason why I have ran into this is because of missing skd version 26 and missing java version 8. Under your build.gradle(app) folder, add the following code to make sure that you have the correct dependencies, default configurations and android compatibilities. You don't need to know what they mean yet, just know they exist. Basically you are trying to make sure that Android can read previous version of things. Here is the code that I run to ensure that my apps run.
apply plugin: 'com.android.application'
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
compileSdkVersion 26
compileSdkVersion 27
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.firstfirstapp"
minSdkVersion 16
targetSdkVersion 26
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "androidx.cardview:cardview:1.0.0"
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.android.support:appcompat-v7:26.0.0'
}
add this line:- multiDexEnabled true in build. gradle
in` defaultConfig {
...
multiDexEnabled true
}
Also make minsdk = 26
try this:
defaultConfig {
...
multiDexEnabled true
}
If you are trying to run apk directly from android studio, please try to avoid enabling
minifyEnabled true
Comment the following line.
// minifyEnabled true
// shrinkResources true
But you can use above line while building apk.

Crashing app after implementation Sceneform

I'm struggling with a strange issue.
I tried everything to find a solution to why my app crashes.
The reason is "implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.7.0' ".
When I add this implementation I get error:
java.lang.RuntimeException: Unable to instantiate activity
ComponentInfo{com.example.myarcore/com.example.myarcore.MainActivity}:
java.lang.ClassNotFoundException: Didn't find class
"com.example.myarcore.MainActivity" on path: DexPathList[[zip file
"/data/app/com.example.myarcore-Aw
This is my app gradle code:
apply plugin: 'com.android.application'
apply plugin: 'com.google.ar.sceneform.plugin'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.myarcore"
minSdkVersion 26
targetSdkVersion 28
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
According to MultiDex documentation if app min sdk is higher than 21 then to enable MultiDex all I need is to put multiDexEnabled true as I did.
SOLVED,
My min SDK was set to 26.
Just add this to your app gradle, even when documentation says that is necessary in min SDK lower than 26.
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

Why "This app has been built with an incorrect configuration" error occured in some phones?

I Have build my app in android 6 without any error, but when I build my app in android 4.4.2 I get this error
This app has been built with an incorrect configuration.
Please configure your build for VectorDrawableCompat.
and this is my gradle:
android {
compileSdkVersion 24
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "com.faranegar.channel"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
note: when I set compileSdkVersion 23, every thing is fine and there isn't any error.
This worked well for me
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
generatedDensities = []
}
// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
additionalParameters "--no-version-vectors"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Notice this in the above code:
// This is handled for you by the 2.0+ Gradle Plugin
aaptOptions {
additionalParameters "--no-version-vectors"
}
and
generatedDensities = []
UPDATE
If this generatedDensities = [] is showing deprecated, use the following instead.
vectorDrawables.generatedDensities = []
Hope it helps
This issue was alread reported here Issue 214182: appcompat-v7 24.0.0 is incompatible with rasterized vectors.
One of the developer mention:
What version of the Gradle plugin are you using?
As of v2.0 of the Gradle plugin, library resources are never
rasterized so this should never happen.
The workaround for this is to update your Gradle by following this official link. Android Plugin for Gradle Release Notes.
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
if you are using rasterized vector drawables
for Gradle plugin 2.0+
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
...
}
}
for Gradle plugin before 2.0
android {
defaultConfig {
generatedDensities = []
...
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
you should add appcompat-v7 23.2.0+ to your build.gradle.for me,i am using
compile 'com.android.support:appcompat-v7:23.4.0'
This happened to me while implementing unit tests with JUnit and Robolectric. If that's your case maybe you need to add this to your gradle file, inside the android section. That's how I fixed it:
testOptions {
unitTests {
includeAndroidResources = true
}
}

Changing Android versionCode causes build.gradle error

I just upgraded my Android Studio to 1.4.1.
In build.gradle, When i change my versionCode,
import org.apache.commons.lang3.JavaVersion
gets added to the top of build.gradle, which causes the error:
build file '/../app/build.gradle': 1: unable to resolve class org.apache.commons.lang3.JavaVersion
# line 1, column 1.
import org.apache.commons.lang3.JavaVersion
When I remove the line import org.apache.commons.lang3.JavaVersion, it gets added back automatically after a while.
When I revert the versionCode back to 1, the import statement disappears and all is well.
Gradle File
import org.apache.commons.lang3.JavaVersion
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "com.x.app"
minSdkVersion 14
targetSdkVersion 22
versionCode 2
versionName "1.0.1"
renderscriptTargetApi 19
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
}
}
How do i solve this issue?
Thanks!
Simply remove the import.
Your versionCode line in build.gradle should look like this :
versionCode 3
You use this class on compileOptions. That has nothing to do with pour versionCode, which is just fine.
Java 8 is not supported in Android, so I guess your problem is here

Gradle error in Android

Anyone know what I'm missing? My program worked 5 minutes ago and know I have this strange error:
17:16:38 UnsupportedMethodException
Unsupported method: AndroidArtifactOutput.getOutputFile().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.: Unsupported method: AndroidArtifactOutput.getOutputFile().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model.
I can't ignore it because I can not run it anymore on my android device, anyone?
Build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.example.test.google_maps_task_1"
minSdkVersion 11
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:4.2.42'
compile 'com.android.support:appcompat-v7:21.+'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
}
As I thought, there are many out of date plugins/tools here. Please try this fixed and updated build.gradle:
Also, make sure you are using the latest build plugin: com.android.tools.build:gradle:1.1.3.
apply plugin: 'com.android.application'
android {
compileSdkVersion 22 // <-- was 21
buildToolsVersion "22.0.1" // <-- was 20.0.0
defaultConfig {
applicationId "com.example.test.google_maps_task_1"
minSdkVersion 11
targetSdkVersion 22 // <-- was 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:6.5.87' // <-- was 4.2.42
compile 'com.android.support:appcompat-v7:22.0.0' // <-- was 21.+
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1' // (the only up to date plugin you had)
}

Categories

Resources