I an trying to import Ksoap2 library in android studio using .jar file version 3.6.4. I have successfully implemented the jar file to android studio. However, on the module app activity when I try to import e.g. import "org.ksoap2.SoapEnvelope;", it gets and error it shows following results:
Execution failed for task ':app:checkDebugAarMetadata'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not find com.google.code.ksoap2-android:ksoap2-android:3.6.4.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/com/google/code/ksoap2-android/ksoap2-android/3.6.4/ksoap2-android-3.6.4.pom
- https://dl.google.com/dl/android/maven2/com/google/code/ksoap2-android/ksoap2-android/3.6.4/ksoap2-android-3.6.4.pom
- https://jcenter.bintray.com/com/google/code/ksoap2-android/ksoap2-android/3.6.4/ksoap2-android-3.6.4.pom
Required by:
project :app
Possible solution:
Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
Also the imports library have error, please see the pic:
Here is the Build.gradle module code:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is Build.gradle(app) Module code:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.kowloondairycompanykdl.milk_ic"
minSdkVersion 27
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'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation files('libs\\ksoap2-android-assembly-3.6.4.jar')
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.code.ksoap2-android:ksoap2-android:3.6.4'
}
Please help me, I been stuck here for a long time. How to fix the error and how can I implement the Ksoap2 library properly. Thanks
There doesn't seem to be a 3.4.3 version of that library. There's a 3.4.0. And the newest is 3.6.4. You're going to need to use one of those. I'd move to 3.6.4 as 3.4.0 is over 5 years old, and likely lacks security updates.
Remove the dependencyResolutionManagement block from the setting.gradle file to have your project work the old way.
Related issue: Build was configured to prefer settings repositories over project repositories but repository 'maven' was added by build file 'build.gradle'
Related
Hello I'm trying to use the Dagger Hilt library In my project but when I'm trying to build it, it fails with this message
public final class MyApplication extends android. app.Application {
^
Expected #HiltAndroidApp to have a value. Did you forget to apply the Gradle Plugin? (dagger.hilt.android.plugin)
See https://dagger.dev/hilt/gradle-setup.html
[Hilt] Processing did not complete. See the error above for details.
And then a java file called MyApplication.java opens with the below content:
package com.example.hilt;
import android.app.Application;
import dagger.hilt.android.HiltAndroidApp;
import kotlin.reflect.KClass;
#kotlin.Metadata(mv = {1, 5, 1}, k = 1, d1 = {"\u0000\f\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0007\u0018\u00002\u00020\u0001B\u0005\u00a2\u0006\u0002\u0010\u0002\u00a8\u0006\u0003"}, d2 = {"Lcom/example/hilt/MyApplication;", "Landroid/app/Application;", "()V", "app_debug"})
#dagger.hilt.android.HiltAndroidApp
public final class MyApplication extends android.app.Application {
public MyApplication() {
super();
}
}
this is my project build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.5.20"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.dagger:hilt-android-gradle-plugin:2.37'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And this is my app module build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'dagger.hilt.android.plugin'
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.hilt"
minSdkVersion 21
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'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//Dagger - Hilt
implementation "com.google.dagger:hilt-android:2.37"
kapt "com.google.dagger:hilt-android-compiler:2.37"
}
kapt {
correctErrorTypes true
}
as you see I did everything correctly and it still gives me the error. I tested my code on another computer and it worked! I even removed android studio, Gradle, and SDK manager from my computer and reinstall them but it still gives me the error.
How can I fix it?
I finally found the solution. Here you can see an issue related to support for Kotlin's plugin 1.5.20 and as it explains this is the bug of Kotlin's plugin, not dagger hilt's!
The solution is simple, you have to add this code to your build.gradle app module:
kapt {
javacOptions {
option("-Adagger.hilt.android.internal.disableAndroidSuperclassValidation=true")
}
}
Edit:
Just update the Kotlin plugin to the latest version and change ext.kotlin_version to the latest version in project-level build.gradle. The current version is 1.5.21.
Just change the version of this below classpath in your project level gradle to the latest version -
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:VERSION_TO_CHANGE"
I have the same problem on fresh project. And problem was in wrong gradle path.
I specified in local.properties this:
org.gradle.java.home=/Users/cmx/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/203.7935034/Android Studio.app/Contents/jre/Contents/Home
And it helps me.
you did not add annotationProcessor check following link https://dagger.dev/hilt/gradle-setup.html
add like this in your app.gradle
implementation 'com.google.dagger:hilt-android:2.37'
annotationProcessor 'com.google.dagger:hilt-compiler:2.37'
Link
https://developer.android.com/codelabs/build-your-first-android-app#8
Code:-
Build.gradle(:app) :-
plugins {
apply plugin: 'com.android.application'
apply plugin: 'androidx.navigation.safeargs'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.layouteditor"
minSdkVersion 16
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'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
build.gradle(LayoutEditor):-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:4.1.3"
def nav_version = "2.3.0-alpha04"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And I get this error:-
A problem occurred configuring root project 'LayoutEditor'.
Could not resolve all artifacts for configuration ':classpath'.
Could not find com.android.tools.build:gradle:4.1.3.
Searched in the following locations:
- https://jcenter.bintray.com/com/android/tools/build/gradle/4.1.3/gradle-4.1.3.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project :
Could not find androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0-alpha04.
Searched in the following locations:
- https://jcenter.bintray.com/androidx/navigation/navigation-safe-args-gradle-plugin/2.3.0-alpha04/navigation-safe-args-gradle-plugin-2.3.0-alpha04.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project :
Possible solution:
Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
I have gone through solutions of similar question asked by other on stackoverflow.
I have put right code in right gradle file.
I tried code from Android developers >> Jetpack >> Libraries (click below link)
https://developer.android.com/jetpack/androidx/releases/navigation#safe_args but getting more errors
and I have also gone through above Android Studio's suggested possible solution but didn't understand it. Please help if anyone have faced same problem and have solution.
The reason of this is may using a different version of plugin.
Try to use following lines in your build.gradle(LayoutEditor):
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.2"
Instead of
def nav_version = "2.3.0-alpha04"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
Use line following lines for apply plugin
'androidx.navigation.safeargs.java'
If you use kotlin then
'androidx.navigation.safeargs.kotlin'
This may solve your problem.
Replace 2.3.0-alpha04 with 2.3.0 or newer version and rebuilt your project. It should work.
im trying to build my app on android studio but im getting this error
"AAPT2 process unexpectedly exit. Error output"
i search about it and tryed everything to solve this but dosent help me.
android studio version:4.1.1
gradle version: 6.8-rc5
This is my gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And this is gradle(mudle)
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.weather5"
minSdkVersion 16
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'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
So,finaly someone from Twitter helpd me and solve the problem.
The solution is:
The main cause of the problem is the instability of the android gradle plugin version and gradle version.
You can easily change these versions through the project structcher from the file menu or you can use the command ctrl + alt + shift + S to reach project structur.
My setting is This:
android gradle plugin version: 4.0.1
gradle version: 6.1.1
Be aware that versions SHOULD NOT contain alpha or beta.
Also you can use this link to finde out Which gradle plugin and gradle vesrion are Suitable for each other
After the new update of Android Studio (3.3.0) I'm getting error from Gradle sync saying "ERROR: Cause: invalid type code: 68". Even in project, that have been created before the update and hasn't changed at all.
I've tried to reinstall Android Studio, which hasn't helped either, so there has to be something incompatible with my project, but it doesn't say what and why.
App gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "cz.cubeit.cubeit"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:cardview-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.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
}
Project gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.11'
ext.anko_version='0.10.7'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I had the same problem. I was working on a project on two PCs: one at my office and one at home. In my office, after the AS 3.3 update, everything was fine but at home, after the same steps that I did at the office, the Error code 68 came out.
After a couple of hours, I figured out how to solve it.
Android Studio 3.3 has the " Only sync the active variant" option enabled by default in Settings>Experimental. Disabling this feature resolved the problem. But reactivating the feature the same error shows up, even after a successful Gradle sync. So I think this isn't a complete solution, but at least now I can work.
I had the same issu with IntelliJ 2019.1, Untick this option works for me.
Alter path JDK location to .....\Android Studio\jre
I got a similar message ("invalid type code: E5") and resolved it by first building from the command line, which revealed it was a Firebase libs version conflict, and then switching to use firebase-bom instead of manually specifying each version.
I had the same error (6C) during a LinkedIn Learning course, I managed to solve it through the following steps
Updating Kotlin in project-level build.gradle file
Update gradle build version in project-level build.gradle file.
Open Project Structure and using the Suggestions tab, update all modules to the latest version.
Update the compileSdkVersion & targetSdkVersion to latest.
I am getting the following error when trying to compile the project:
error: package lombok does not exist
And others stating that all the annotations from it can't be found.
I don't see errors in code before compiling and I didn't have this error while I was using Android Studio 3 RC1.
Here are my gradle scripts:
Project level:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-rc2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App module level:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.mk.forum"
minSdkVersion 25
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.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.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile project (':util')
compile project (':forum_core')
compileOnly 'org.projectlombok:lombok:1.16.18'
annotationProcessor 'org.projectlombok:lombok:1.16.18'
compile group: 'com.github.javafaker', name: 'javafaker', version: '0.13'
}
I've got modules too, but I think it isn't important.
I hope it is because of compileOnly annotation. Here is the doc:
blog.gradle.org/introducing-compile-only-dependencies
Dependencies required at compile time but never required at runtime, such as source-only annotations or annotation processors;
Dependencies required at compile time but required at runtime only when using certain features, a.k.a. optional dependencies;
Dependencies whose API is required at compile time but whose implementation is to be provided by a consuming library, application
or runtime environment.
It might be related to jdk9. I know that the combination of IntelliJ, lombok 1.16.18 and jdk9 currently doesn't work. But that does not explain your error message. We expect that we can release 1.16.20 within a few days (maybe tonight) that addresses this problem.
Disclosure: I am a lombok developer.