Added a dependency, but can not import anything - android

This is a total newb question and I believe it has a very simple solution. My problem is that an imported dependency is not accessible from my MainActivity.kt. I added it like any other dependency and according to the library docs. And I simply can't import the classes I need. They are missing. Any advice?
build.gradle (Module: MyApp)
dependencies {
...
implementation 'com.thelittlefireman:AppKillerManager:2.1.1'
}
Rebuilding the project gives me this error:
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find com.thelittlefireman:AppKillerManager:2.1.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/thelittlefireman/AppKillerManager/2.1.1/AppKillerManager-2.1.1.pom
- https://repo.maven.apache.org/maven2/com/thelittlefireman/AppKillerManager/2.1.1/AppKillerManager-2.1.1.pom
Required by:
project :app

Added jcenter repository (or whatever it's called) to settings.gradle.
settings.gradle
dependencyResolutionManagement {
repositories {
...
jcenter()
}
}

Related

Why removing jcenter() repository fails my Android Application build for sqlite-android:3.36.0

I've updated my Android Application gradle to use AGP 7.0
my gradle repositories resembles this
repositories {
google()
mavenCentral()
jcenter()
}
This shows that JCenter Maven repository is no longer receiving updates: newer library versions may be available elsewhere
When I remove jcenter() my build fails with this error
* What went wrong:
Execution failed for task ':app:mergeDevelopmentDebugNativeLibs'.
> Could not resolve all files for configuration ':app:developmentDebugRuntimeClasspath'.
> Could not find io.requery:sqlite-android:3.34.1.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/io/requery/sqlite-android/3.34.1/sqlite-android-3.34.1.pom
- https://repo.maven.apache.org/maven2/io/requery/sqlite-android/3.34.1/sqlite-android-3.34.1.pom
Required by:
project :app > project :background:worker > project :background:database
As my application employs api 'io.requery:sqlite-android:3.34.1'
The requery GitHub README.md file states I need to use the following gradle entry
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
However adding the above does not fix my gradle build error
Where am I going wrong?
I updated to sqlite-android:3.36.0 and stil get...
* What went wrong:
Execution failed for task ':app:mergeDevelopmentDebugNativeLibs'.
> Could not resolve all files for configuration ':app:developmentDebugRuntimeClasspath'.
> Could not find io.requery:sqlite-android:3.36.0.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/io/requery/sqlite-android/3.36.0/sqlite-android-3.36.0.pom
- https://repo.maven.apache.org/maven2/io/requery/sqlite-android/3.36.0/sqlite-android-3.36.0.pom
- https://jitpack.io/io/requery/sqlite-android/3.36.0/sqlite-android-3.36.0.pom
Required by:
project :app > project :background:worker > project :background:database
I have identified the issue
When I have this entry my build works:-
implementation 'com.github.requery:sqlite-android:3.36.0'
When I have this entry my build fails:-
api 'com.github.requery:sqlite-android:3.36.0'

Could not resolve all files for configuration: ':app:debugRuntimeClasspath'

I am attempting to implement a third party SDK bundle when I ran react-native run-android I got the following error:
Execution failed for task ':app:checkDebugAarMetadata'.
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not resolve com.ts.auth-control-sdk:5.1.1.
Required by:
project :app
> Could not resolve com.ts:auth-control-sdk:5.1.1.
> Could not get resource 'https://www.jitpack.io/com/ts/auth-control-sdk/5.1.1/auth-control-sdk-5.1.1.pom'.
> Could not GET 'https://www.jitpack.io/com/ts/auth-control-sdk/5.1.1/auth-control-sdk-5.1.1.pom'.
> sun.security.validator.Validator.Exception: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to
find valid certification path to requested target
Inside of my app/build.gradle file, I have the following setup:
dependencies {
...
implementation "com.ts:auth-control-sdk:5.1.1:arr"
...
}
Inside my android/build.gradle file I have the following:
allprojects {
repositories {
...
maven {
url("$rootDir/../com/ts/auth-control-sdk/5.1.1")
}
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
I am not even sure whether this third-party SDK even exists inside of Jitpack repository.
Did I err in the way I implemented the dependency?
As far as the maven directory, per the documentation I placed a folder called com/ inside the root folder of the mobile app and the folder structure of it is: com > ts > auth-control-sdk > 5.1.1
It seems as though if it's inside of maven {} it will go to Jitpack repo and look for library as opposed to just going to the root folder of the project. Am I correct in this conclusion?
By the way I placed it inside of maven {} because their documentation says to do so.
Could it be that $rootDir is what indicates to maven to go look at Jitpack since below all the libraries there is that:
maven { url 'https://www.jitpack.io' }
Am I correct in concluding that $rootDir is referencing that jitpack url and not the root directory of the application?
Well, I gave it a shot and came away with the same exact error.
I believe I am correctly notating the file in accordance with this documentation:
https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/dsl/DependencyHandler.html
I am not notating it like so: implementation ("com.ts:auth-control-sdk-5.1.1#arr") { transitive=true }
and removed the following : maven { url 'https://www.jitpack.io' }
But then I get this error:
Execution failed for task ':app:checkDebugAarMetadata'.
Could not resolve all the files for configuration 'app:debugRuntimeClasspath'.
Could not find com.ts:auth-control-sdk-5.1.1:.
Required by
project :app
What worked for me was inside of android/build.gradle:
maven {
url("$rootDir/..")
}
I also removed:
maven {
url { www.jitpack.io/ }
}
So that it would not keep going to the Jitpack repo to look for that local directory.
Then inside of app/build.gradle:
dependencies {
...
implementation('com.ts:auth-control-sdk:5.1.1#aar') { transitive=true }
}
**go to your setting.gradle and write the below line of code for the the control
of
libraries or dependencies **
maven { url 'https://jitpack.io' }
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
jcenter() // Warning: this repository is going to shut down soon
maven { url 'https://jitpack.io' }
}
}
rootProject.name = "Xyz"
include ':app'
If you have facing Gradle dependencies iss> Task :app:mergeDebugNativeLibs FAILED
Error Image
FAILURE: Build completed with 6 failures.
Execution failed for task ':app:checkDebugDuplicateClasses'. Execution
failed for task ':app:desugarDebugFileDependencies'. Execution failed
for task ':app:checkDebugAarMetadata'. Execution failed for task
':app:mergeDebugAssets'. Execution failed for task
':app:mergeDebugAssets'. Execution failed for task
':app:mergeDebugNativeLibs'.ue
in android studio?
Answer:
If you using ANDROID 11 in your project then try the below options
Go to settings
Click option to Gradle, Execution, deployment
Then click build Tools
Solution Image
choose to gradle
Then disable the offline mode then Run

How do I add dependencies to the root-level build.gradle file in my Codename One Android app?

I already added the android.gradleDep build hint with the proper "compile'....' " hint for the 3rd party library I want to integrate. (In this case, Firebase).
In the root-level build.gradle file in a Codename One Android app, how can I:
add a classpath dependency to the buildscript section?
add a maven dependency in the allprojects section?
EDIT:
3. Add a plugin, such as: apply plugin: 'com.google.gms.google-services'
For a visual example:
buildscript {
dependencies {
classpath 'com.google.gms:google-services:3.1.0' // google-services plugin
}
}
allprojects {
dependencies {
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
}
I have looked at CN1's page on Build hints but don't know what to do next to import this library. Without these changes, I get the following build error:
Resource missing. [HTTP GET: https://jcenter.bintray.com/com/google/firebase/firebase-
core/11.2.0/firebase-core-11.2.0.pom]
Resource missing. [HTTP HEAD: https://jcenter.bintray.com/com/google/firebase/firebase-
core/11.2.0/firebase-core-11.2.0.jar]
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'MyApp'.
> Could not resolve all dependencies for configuration ':_debugCompile'.
> Could not find com.google.firebase:firebase-core:11.2.0.
Searched in the following locations:
https://jcenter.bintray.com/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.pom
https://jcenter.bintray.com/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.jar
file:/tmp/build1801628445736809063xxx/MyApp/libs/firebase-core-11.2.0.jar
file:/tmp/build1801628445736809063xxx/MyApp/libs/firebase-core.jar
file:/home/ec2-user/android-sdk/extras/android/m2repository/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.pom
file:/home/ec2-user/android-sdk/extras/android/m2repository/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.jar
file:/home/ec2-user/android-sdk/extras/google/m2repository/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.pom
file:/home/ec2-user/android-sdk/extras/google/m2repository/com/google/firebase/firebase-core/11.2.0/firebase-core-11.2.0.jar
EDIT In the .properties file, I have:
codename1.arg.android.repositories=maven { url "https\://maven.google.com" };
codename1.arg.android.gradleDep=compile 'com.google.gms\:google-services\:3.1.0', compile 'com.google.firebase\:firebase-core\:11.2.0'
I am getting the following error message:
FAILURE: Build failed with an exception.
* Where:
Build file '/tmp/build1791213618910744158xxx/MyApp/build.gradle' line: 78
* What went wrong:
A problem occurred evaluating root project 'MyApp'.
> Could not find property 'compile' on org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler_Decorated#59ed76e3.
You can add the build-hint that points to your repo URL as well. In your case:
android.gradleDep=compile 'com.google.gms:google-services:3.1.0'
android.repositories=maven { url "https\://maven.google.com" };

Problems using jitpack.io with Android Gradle

I'm currently trying to add dependencies with jitpack. I've followed the basic instructions:
repositories {
maven {
url "https:jitpack.io"
}
}
dependencies {
compile 'com.github.User:Repo:Tag'
}
But I'm still getting the following error:
What went wrong:
A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugCompile'.
Could not find com.github.jitpack:maven-simple:4f1c2c9033.
Searched in the following locations:
https:/#/jcenter.bintray.com/com/github/jitpack/maven-simple/4f1c2c9033/maven-simple-4f1c2c9033.pom
https:/#/jcenter.bintray.com/com/github/jitpack/maven-simple/4f1c2c9033/maven-simple-4f1c2c9033.jar
https:/#/jitpack.io/com/github/jitpack/maven-simple/4f1c2c9033/maven-simple-4f1c2c9033.pom
https:/#/jitpack.io/com/github/jitpack/maven-simple/4f1c2c9033/maven-simple-4f1c2c9033.jar
https:/#/repo1.maven.org/maven2/com/github/jitpack/maven-simple/4f1c2c9033/maven-simple-4f1c2c9033.pom
https:/#/repo1.maven.org/maven2/com/github/jitpack/maven-simple/4f1c2c9033/maven-simple-4f1c2c9033.jar
file:/C:/sdk/extras/android/m2repository/com/github/jitpack/maven-simple/4f1c2c9033/maven-simple-4f1c2c9033.pom
file:/C:/sdk/extras/android/m2repository/com/github/jitpack/maven-simple/4f1c2c9033/maven-simple-4f1c2c9033.jar
file:/C:/sdk/extras/google/m2repository/com/github/jitpack/maven-simple/4f1c2c9033/maven-simple-4f1c2c9033.pom
file:/C:/sdk/extras/google/m2repository/com/github/jitpack/maven-simple/4f1c2c9033/maven-simple-4f1c2c9033.jar
Required by:
Plate:app:unspecified
Your jitpack url looks wrong.
It's:
url "https:jitpack.io"
but in my opinion it should be:
url "https://jitpack.io".

Gradle project refresh failed (AS 0.8.2, Mac)

With a blank new project, I get this:
Gradle 'HelloWorld' project refresh failed
Error:Cause: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
When trying to build I get the following Gradle Build error:
Error:A problem occurred configuring root project 'HelloWorld'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:0.12.+.
Required by:
:HelloWorld:unspecified
> org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
This is a fresh installation of Android Studio, and my build.gradle looks like:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
The first lines of the relevant log error are:
org.gradle.tooling.BuildException: Could not run build action using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.12-all.zip'.
Caused by: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring root project 'HelloWorld'.
Caused by: org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project 'HelloWorld'.
Caused by: org.gradle.api.artifacts.ResolveException: Could not resolve all dependencies for configuration ':classpath'.
Caused by: org.gradle.api.internal.artifacts.ivyservice.ModuleVersionResolveException: Could not resolve com.android.tools.build:gradle:0.12.+.
Caused by: java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
The project structure is just the default for a new project with a blank activity:
For me it look like incompatible versions. So this problem is related to this problem: Android Studio says to use Gradle 1.10 - but new version is 1.12?
Try to use gradle 1.10 and delete the the folder of the gradle wrapper.
Try mavenCentral() instead of jcenter()
Looks like this is a known issue..
https://code.google.com/p/android/issues/detail?id=73511

Categories

Resources