I tried to work on Graphhopper demo project on Android Studio, which i found here: https://github.com/graphhopper/graphhopper/tree/master/android
After the Gradle building i got this error:
Error:Failed to resolve: com.graphhopper:graphhopper:0.6-SNAPSHOT
Now Android Studio cannot resolve symbols for Graphhopper classes.
Here is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.graphhopper.android"
minSdkVersion 10
targetSdkVersion 22
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
lintOptions {
/* CGIARProvider refers to java.awt
* Helper7 refers to java.lang.management
* HeightTile refers to javax.imageio and java.awt
* OSMElement refers to javax.xml.stream
*/
disable 'InvalidPackage'
}
}
/** only necessary if you need to use latest SNAPSHOT
configurations.all {
// check for updates every build
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
**/
dependencies {
compile(group: 'com.graphhopper', name: 'graphhopper', version: '0.6-SNAPSHOT') {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
exclude group: 'org.openstreetmap.osmosis', module: 'osmosis-osm-binary'
exclude group: 'org.apache.xmlgraphics', module: 'xmlgraphics-commons'
}
compile group: 'org.mapsforge', name: 'mapsforge-core', version: '0.5.2'
compile group: 'org.mapsforge', name: 'mapsforge-map', version: '0.5.2'
compile group: 'org.mapsforge', name: 'mapsforge-map-android', version: '0.5.2'
compile group: 'org.mapsforge', name: 'mapsforge-map-reader', version: '0.5.2'
compile group: 'org.slf4j', name: 'slf4j-android', version: '1.7.12'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.12'
}
It happens because com.graphhopper:graphhopper:0.6-SNAPSHOT is not in the central maven (or jcenter).
You can check all versions here.
The last stable version is 0.5.0
If you want to use the snapshot versions you have to add a repositoryin your build.gradle
repositories {
jcenter()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
Here the snapshot versions.
Related
I am making a simple KeyAuth app on Android and using this API as an example: https://github.com/SprayDown/KeyAuth-JAVA-api
Below are the function I've been trying to work on and the gradle file for the application.
HttpResponse<String> response;
try {
response = response = Unirest.post(url).field("type", "init").field("ver", version)
.field("name", appname).field("ownerid", ownerid).asString();
} catch (UnirestException e) {
e.printStackTrace();
}
Above is the code I've been trying to run and getting the error. And here is my gradle file:
plugins {
id 'com.android.application'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.mercyz.regvnapk"
minSdk 24
targetSdk 31
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
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation group: 'commons-codec', name: 'commons-codec', version: '1.15'
implementation group: 'commons-logging', name: 'commons-logging', version: '1.2'
implementation group: 'org.apache.httpcomponents', name: 'httpasyncclient', version: '4.1.4'
implementation group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13'
implementation group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.14'
implementation group: 'org.apache.httpcomponents', name: 'httpcore-nio', version: '4.4.14'
implementation group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.5.13'
implementation 'net.sourceforge.htmlunit:htmlunit:2.15'
implementation group: 'org.json', name: 'json', version: '20210307'
implementation group: 'com.mashape.unirest', name: 'unirest-java', version: '1.4.9'
// Use JUnit test framework.
testImplementation 'junit:junit:4.13'
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:29.0-jre'
}
Wonder what's going wrong with this.
Hi I want to build this project, the develop branch of it which is 7 commits ahead and have the changes that I want, it requires to manually create a keys.gradle file and put the api keys in, but whatever I do it ends up with an error can someone help me please?
https://github.com/stumi01/Mizuu
here is the build.gradle
apply plugin: 'com.android.application'
apply from: "$rootDir/keys.gradle"
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
def config = defaultConfig {
applicationId "com.miz.mizuu"
minSdkVersion 15
targetSdkVersion 27
multiDexEnabled true
testApplicationId "com.miz.test"
testInstrumentationRunner "android.test.InstrumentationTestRunner"
renderscriptTargetApi 21
renderscriptSupportModeEnabled true
resValue "string", "tmdb_api_key", "${tmdb_api_key}"
resValue "string", "trakt_api_key", "${trakt_api_key}"
}
config
buildTypes {
release {
minifyEnabled false
}
}
packagingOptions {
exclude 'META-INF/beans.xml'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
repositories {
mavenCentral()
mavenLocal()
maven {
url 'http://4thline.org/m2'
}
}
dependencies {
def JETTY_VERSION = "8.2.0.v20160908"
def ANDROID_VERSION = "27.0.2"
implementation "com.android.support:support-v4:$ANDROID_VERSION"
implementation "com.android.support:design:$ANDROID_VERSION"
implementation "com.android.support:appcompat-v7:$ANDROID_VERSION"
implementation "com.android.support:palette-v7:$ANDROID_VERSION"
implementation "com.android.support:recyclerview-v7:$ANDROID_VERSION"
implementation "com.android.support:cardview-v7:$ANDROID_VERSION"
implementation "com.google.guava:guava:24.0-android"
//DI
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation "com.squareup.picasso:picasso:2.5.2"
implementation "com.squareup.retrofit2:retrofit:2.3.0"
implementation "com.squareup.okhttp3:okhttp:3.9.0"
implementation "com.squareup.okio:okio:1.13.0"
implementation "com.squareup:otto:1.3.4"
implementation "com.github.ksoichiro:android-observablescrollview:1.4.0"
implementation "com.jpardogo.materialtabstrip:library:1.0.7"
//Cling (UPNP support)
implementation group: "org.fourthline.cling", name: "cling-core", version:"2.1.1"
implementation group: "org.fourthline.cling", name: "cling-support", version:"2.1.1"
implementation group: 'org.eclipse.jetty', name: 'jetty-server', version: JETTY_VERSION
implementation group: 'org.eclipse.jetty', name: 'jetty-servlet', version: JETTY_VERSION
implementation group: 'org.eclipse.jetty', name: 'jetty-client', version: JETTY_VERSION
//compile files('libs/teleal-common-1.0.13.jar')
//SMB
implementation('jcifs:jcifs:1.3.17'){
exclude group: "javax.servlet"
}
/**
* // Cling 2.0 dependencies on Android
compile group: 'org.slf4j', name: 'slf4j-jdk14', version:'1.7.5'
*/
}
I'm getting this error when I try to build my APK. I'm currently mantaining and buf-fixing this app from another developer. In the gradle he used .+ in every compile. How can I fix it?
The Error:
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/design/widget/CoordinatorLayout.class
The gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'realm-android'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.easyfixapp.easyfix"
minSdkVersion 15
targetSdkVersion 26
multiDexEnabled true
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy {
force 'com.google.code.findbugs:jsr305:3.0.1'
}
}
}
realm {
syncEnabled = true;
}
repositories {
mavenCentral()
}
dependencies {
compile('com.facebook.android:facebook-android-sdk:[4,5)') {
exclude group: 'com.android.support', module: 'multidex'
}
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.theartofdev.edmodo:android-image-cropper:2.6.+'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:support-v4:26.+'
compile 'com.android.support:design:26.+'
compile 'com.android.support:support-vector-drawable:26.+'
compile 'com.android.support:cardview-v7:26.+'
compile 'com.android.support:recyclerview-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:mediarouter-v7:26.+'
compile 'com.google.android.gms:play-services:11.6.0'
compile 'com.google.firebase:firebase-messaging:11.6.0'
compile 'com.prolificinteractive:material-calendarview:1.4.3'
compile 'com.hbb20:ccp:2.0.5'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
compile 'com.github.bumptech.glide:glide:4.2.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.github.chrisbanes:PhotoView:2.0.0'
compile('com.crashlytics.sdk.android:crashlytics:2.8.0#aar') {
transitive = true;
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.2.0'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Remove all of the "+" in your libraries dependency's
version
Try this in your app level gradle file
implementation('com.github.bumptech.glide:glide:4.6.1') {
exclude group: 'com.android.support'
}`
if it does not solve try logging dependencies run this command
./gradlew -q dependencies app:dependencies --configuration compile
in your android studio's Terminal Tab it will log all the dependency tree of your project
then find which libraries are using duplicating dependencies
for example
implementation 'com.github.bumptech.glide:glide:4.6.1'
is using duplicate dependencies so change
implementation 'com.github.bumptech.glide:glide:4.6.1'
to
implementation('com.github.bumptech.glide:glide:4.6.1') {
exclude group: 'com.android.support'
}
In my application i use graphhopper and buttombar. This vividsolution is one of the graphhopper dependencies.
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/vividsolutions/jts/algorithm/Angle.class
this is my build.gradle
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.segunfamisa.sample.bottomnav"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled=true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
lintOptions {
/* CGIARProvider refers to java.awt
* Helper7 refers to java.lang.management
* HeightTile refers to javax.imageio and java.awt
* OSMElement refers to javax.xml.stream
*/
disable 'InvalidPackage'
}
}
}
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:design:25.0.0'
compile 'org.mapsforge:vtm:0.7.0'
compile 'org.mapsforge:vtm-android:0.7.0'
compile('com.graphhopper:graphhopper-core:0.9-SNAPSHOT') {
exclude group: 'com.google.protobuf', module: 'protobuf-java'
exclude group: 'org.openstreetmap.osmosis', module: 'osmosis-osm-binary'
exclude group: 'org.apache.xmlgraphics', module: 'xmlgraphics-commons'
}
compile 'org.mapsforge:vtm-android:0.7.0:natives-armeabi'
compile 'org.mapsforge:vtm-android:0.7.0:natives-armeabi-v7a'
compile 'org.mapsforge:vtm-android:0.7.0:natives-x86'
compile 'org.mapsforge:vtm-jts:0.7.0'
compile 'org.mapsforge:vtm-themes:0.7.0'
compile 'com.caverock:androidsvg:1.2.2-beta-1'
compile 'com.vividsolutions:jts-core:1.14.0'
compile 'org.slf4j:slf4j-api:1.7.21'
compile 'org.slf4j:slf4j-android:1.7.21'
}
Add this to your build.gradle :
configurations {
all*.exclude group: 'com.vividsolutions', module: 'jts-core'
}
It worked for me
You are adding a library like this
(A). compile files('libs/YOUR_LIBRARY.jar')
and this library package already available in your code.
comment it like or remove this line
//compile files('libs/YOUR_LIBRARY.jar')
How to know duplicate-copy of library in your project:
unzip your "YOUR_LIBRARY.jar" and see the same class name in your code.
I've been trying to use the apache.poi library to create an excel file but, for some reason, I'm unable to import anything.
mainClassName = 'Main'
sourceCompatibility = 1.7
targetCompatibility = 1.7
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.api-client:google-api-client:1.22.0'
compile 'com.google.oauth-client:google-oauth-client-jetty:1.22.0'
compile 'com.google.apis:google-api-services-sheets:v4-rev21-1.22.0'
compile 'org.apache.poi:poi:3.9'
}
When I am trying to write import org.apache.poi; it gives me an error saying "Package does not exist".
What is wrong with my dependencies? Thanks.
Some times it is useful to reload a gradle project so gradle could download the binary of the new dependency. After that the new packages should be available.
Found the same error while including gradle in the build.gradle file.
Use:
compile group: 'org.apache.poi', name: 'poi', version: '3.9'
Like: dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile group: 'org.apache.poi', name: 'poi', version: '3.9'
compile 'com.android.support:appcompat-v7:23.4.0'
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "fl.gauravsngarg.com.inventory"
minSdkVersion 23
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 group: 'org.apache.poi', name: 'poi', version: '3.9'
compile 'com.android.support:appcompat-v7:23.4.0'
}
After research I found the actual version.
Use
// https://mvnrepository.com/artifact/org.apache.poi/poi
compile group: 'org.apache.poi', name: 'poi', version: '3.9'
Its given here
https://mvnrepository.com/artifact/org.apache.poi/poi/3.9
The site contains all the official dependencies for gradle, maven, etc.
It worked for me:
It is quite possible that you have enabled gradle sync in offline mode.
Just change that.
Works like a charm
I had the same issue!
For me File > Invalidate Chaches / Restart > Invalidate and Restart worked.
I am using this version: https://mvnrepository.com/artifact/org.apache.poi/poi/4.1.2
Worked for me:
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '4.0.0'