Remote jar not found in build.gradle - android

In my application (MyApp), I am using an another project(Appox) as library and in this (Appox) project, I want to include bugsense-jar from their repository. Now in build.gradle of Appox, I am including it in this way
apply plugin: 'android-library'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
repositories {
mavenCentral()
maven { url 'http://www.bugsense.com/gradle/' }
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.bugsense.trace:bugsense:3.6'
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
sourceSets {
main {
//....
}
}
}
But on compiling I am always getting the error Failed to find com.bugsense.trace:bugsense:3.6
Am I including it in the correct way? Is it possible that the file is not even present in their repo?

Just to bring this up to date, Bugsense has been renamed Mint, so the references to the bugsense.com repo are broken. So, update your Gradle file with the following:
apply plugin: 'android'
repositories {
maven { url "https://mint.splunk.com/gradle/" }
}
dependencies {
compile "com.splunk.mint:mint:4.3.0"
}
From: http://docs.splunk.com/Documentation/MintAndroidSDK/latest/DevGuide/Requirementsandinstallation
If you're updating old code, you'll also need to update your imports and rename any instances of BugSenseHandler in your code to Mint. (http://docs.splunk.com/Documentation/MintAndroidSDK/latest/DevGuide/AddSplunkMINTtoyourproject)

Try something like this :
apply plugin: 'android-library'
buildscript {
repositories {
maven { url 'http://www.bugsense.com/gradle/' }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.12.+'
compile 'com.bugsense.trace:bugsense:3.6'
}
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
sourceSets {
main {
....
}
}
}
Changes made :
All Maven repositories declared at the same time
mavenCentral() is declared in the last position
Sources :
http://blog.bugsense.com/post/58900337206/gradle-repository-is-now-available-for-bugsense
http://gradleproject.wordpress.com/2013/02/14/multiple-maven-repositories-in-gradle/

Related

NoClassDefFoundError for web3j.httpClient

I've programmed an android library which uses the org.web3j:core:4.6.0-android dependency. Now I've exported my library as a .aar and imported as a new module into a android application. I can build and run the application but as soon as a function uses the web3j:httpClient it throw the exception: NoClassDefFoundError for web3j.httpClient...
How can I solve this issue?
This is my build-gradle of my application, the example_sdk part is my android library using web3j:
group 'io.test.test_plugin'
version '1.0'
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
rootProject.allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'java/libs'
}
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
defaultConfig {
minSdkVersion 19
}
lintOptions {
disable 'InvalidPackage'
}
}
dependencies {
implementation project(path: ':example-sdk')
implementation "androidx.core:core-ktx:+"
}
repositories {
mavenCentral()
}

Integrating Crashlytics in a multi-module project

I have an Android project with a main module plus multiple other sub-modules. I integrated Crashlytics in the project successfully, by updating the project-level build.gradle and the main module build.gradle:
Project-level gradle:
buildscript {
repositories {
jcenter()
maven {url 'https://maven.google.com'}
maven {url 'https://maven.fabric.io/public'}
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'io.fabric.tools:gradle:1.31.2'
}
}
allprojects {
repositories {
jcenter()
google()
maven {url 'https://maven.fabric.io/public'}
}
}
Main-module build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
android {
...
}
dependencies {
implementation ('com.crashlytics.sdk.android:crashlytics:2.10.1') {
transitive = true;
}
...
implementation project(':modules:sensordata:collection:ambient:module-wifinetwork')
...
}
repositories {
maven { url 'https://dl.bintray.com/rvalerio/maven' }
maven {
url 'https://maven.google.com/'
name 'Google'
}
google()
jcenter()
}
build.gradle for module module-wifinetwork (similar for every module):
apply plugin: 'com.android.library'
android {
compileSdkVersion 29
defaultConfig {
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility = 1.8
sourceCompatibility = 1.8
}
}
dependencies {
implementation ('com.crashlytics.sdk.android:crashlytics:2.10.1') {
transitive = true;
}
...
}
My problem is that crash reports from the main-module are correctly sent to the firebase backend, while crash reports in other modules are not, even though they are correctly identified, because if I put this command in a class in the sub-module:
Crashlytics.getInstance().crash();
I receive the following:
2019-12-18 10:19:54.328 29944-30002/it.unitn.disi.witmee.sensorlog E/EventBus: Could not dispatch event: class it.unitn.disi.witmee.modules.core.systembus.model.BusObject to subscribing class class it.unitn.disi.witmee.modules.core.systembus.core.SensorlogMainBus
java.lang.ArrayIndexOutOfBoundsException: length=2; index=10
at com.crashlytics.android.core.CrashTest.indexOutOfBounds(CrashTest.java:30)
at com.crashlytics.android.core.CrashlyticsCore.crash(CrashlyticsCore.java:635)
at com.crashlytics.android.Crashlytics.crash(Crashlytics.java:340)
at it.unitn.disi.witmee.modules.sensordatacollection.ambient.wifinetwork.runnables.SensorRunnable.run(SensorRunnable.java:38)
at it.unitn.disi.witmee.modules.sensordatacollection.sensormodule.receivers.StartAllBroadcastReceiver.busEventCallback(StartAllBroadcastReceiver.java:23)
at it.unitn.disi.witmee.modules.core.systembus.core.SensorlogMainBus.onEvent(SensorlogMainBus.java:219)
at java.lang.reflect.Method.invoke(Native Method)
at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:507)
at org.greenrobot.eventbus.EventBus.invokeSubscriber(EventBus.java:501)
at org.greenrobot.eventbus.BackgroundPoster.run(BackgroundPoster.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Any clue why this is not working in the sub-module? Thank you
I found the issue, just had to rebuild the project. So the solution is to add the following elements to the project-level build.gradle and to the main-module build.gradle, nothing to be added to individual modules build.gradle. And then clean and rebuild your project.
Project-level build.gradle:
buildscript {
repositories {
...
maven {url 'https://maven.fabric.io/public'}
...
}
dependencies {
...
classpath 'io.fabric.tools:gradle:1.31.2'
}
}
allprojects {
repositories {
...
maven {url 'https://maven.fabric.io/public'}
}
}
Main-module build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
android {
...
}
dependencies {
implementation ('com.crashlytics.sdk.android:crashlytics:2.10.1') {
transitive = true;
}
...
repositories {
...
}

Copy task in Gradle not found

I am developing an app in Unity and need to copy some files before the build.
I have looked around for how to do this and this is what I created (I removed all the "noise"):
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
}
}
allprojects {
repositories {
flatDir {
dirs 'libs'
}
}
}
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
android {
compileSdkVersion 25
.....
buildTypes {
.......
}
preBuild.dependsOn copyRes
}
task copyRes(type: Copy) {
from file("'../../Assets/Plugins/Android/res")
into file("./src/main/res/values")
}
My build is failing with the following error:
Could not get unknown property 'copyRes' for object of type com.android.build.gradle.AppExtension
This is just an ordering issue. You have tried to use copyRes before it exists.
Option 1 - Use a string instead of the variable
preBuild.dependsOn 'copyRes'
Option 2 - Declare the copyRes task first, before the android {...} block

android can't add one singnal

I am trying to one signal to my project and i add dependencies like this
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.8.1'
}
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
repositories {
maven { url 'https://maven.google.com' }
}
and in my build.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.2.1'
classpath 'io.fabric.tools:gradle:1.24.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'http://jhoobin.abroid.com/repo/' }
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
google()
}
}
but i keep getting error when i sync the gradle
Error:Unable to resolve dependency for ':app#debug/compileClasspath': Could not find any version that matches com.google.android.gms:play-services:15.+.
Open FileShow Details
what is wrong with my code ?
These are my gradles.
This is my :app gradle
//noinspection GradleCompatible
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.app.app"
manifestPlaceholders = [onesignal_app_id: "APP_ID_HERE",
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: "PROJECT_NUMBER_HERE"]
minSdkVersion 15
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'])
compile files('libs/commons-io-2.4.jar')
compile 'com.google.firebase:firebase-core:10.2.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.onesignal:OneSignal:3.+#aar'
// Required for OneSignal, even if you have added FCM.
compile 'com.google.android.gms:play-services-gcm:10.2.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
My main projects 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.3'
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
}

issue to add a repository from android arsenal

I am trying to add a PinnedSectionListView from android arsenal.
the way to add say:
Add the specific repository to your build file:
repositories {
maven {
url "https://jitpack.io"
}
}
Add the dependency in your build file (do not forget to specify the correct qualifier, usually 'aar'):
dependencies {
compile 'com.github.beworker:pinned-section-listview:v1.0'
}
so i did that (build.gradle (Project)):
buildscript {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://jitpack.io"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (Module): apply plugin: 'com.android.application'
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.jonathandg.listviewsections"
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.1.0'
compile 'com.beworker:pinned-section-listview:v1.0#aar'
//compile 'com.beworker:pinned-section-listview:v1.0'
}
then the android studio message is
Error:(25, 13) Failed to resolve: com.beworker:pinned-section-listview:v1.0
The repositoty is in: https://android-arsenal.com/details/1/264
Try below Gragle dependency line
compile 'com.github.beworker:pinned-section-listview:1.1'

Categories

Resources