I am building an Android library using maven.
Works fine, I can import the jars into an normal Android Studio Project, everything working fine.
However, when I try to build a Unity project using the exact same jars, I get following error: File 'META-INF/LICENSE' exists in both
So maven is creating those files in both jars.
I did not found anything on how to tell maven to only copy it into one jar, or in none.
Anyone an idea how to fix that problem?
Cheers
You can use with Custom Gradle.
Android build setting
Custom Gradle file
buildscript {
repositories {**ARTIFACTORYREPOSITORY**
google()
jcenter()
maven {
url "maven url"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.0'
**BUILD_SCRIPT_DEPS**}
}
allprojects {
repositories {**ARTIFACTORYREPOSITORY**
google()
jcenter()
flatDir {
dirs 'libs'
}
maven {
url "maven url"
}
}
}
apply plugin: 'com.android.application'
**APPLY_PLUGINS**
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
compileOnly files ('libs/unity-classes.jar')
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
**DEPS**}
android {
compileSdkVersion **APIVERSION**
buildToolsVersion '**BUILDTOOLS**'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
minSdkVersion **MINSDKVERSION**
targetSdkVersion **TARGETSDKVERSION**
applicationId '**APPLICATIONID**'
ndk {
abiFilters **ABIFILTERS**
}
versionCode **VERSIONCODE**
versionName '**VERSIONNAME**'
}
lintOptions {
abortOnError false
}
aaptOptions {
noCompress = ['.unity3d', '.ress', '.resource', '.obb'**STREAMING_ASSETS**]
ignoreAssetsPattern = "!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~"
}**SIGN**
buildTypes {
debug {
minifyEnabled **MINIFY_DEBUG**
useProguard **PROGUARD_DEBUG**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD****SIGNCONFIG**
jniDebuggable true
}
release {
minifyEnabled **MINIFY_RELEASE**
useProguard **PROGUARD_RELEASE**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-unity.txt'**USER_PROGUARD****SIGNCONFIG**
}
}**PACKAGING_OPTIONS****SPLITS**
**BUILT_APK_LOCATION**
**EXTERNAL_SOURCES**
bundle {
language {
enableSplit = false
}
density {
enableSplit = false
}
abi {
enableSplit = true
}
}
}**SPLITS_VERSION_CODE****REPOSITORIES****SOURCE_BUILD_SETUP**
Related
I am trying to generate allure report for android tests, but when I run command .\gradlew clean test, only testcases in test folder are there in the report. there are no tests from androidTest package. is there something wrong in the command or the build.gradle file. I am new to this, not able to figure it out.
I am using Android studio. Attaching build.gradle script.
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "io.qameta.allure.gradle.allure:allure-plugin:2.11.2"
}
}
plugins {
id 'com.android.application'
id "io.qameta.allure" version "2.11.2"
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.tabbedactivity"
minSdk 21
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunner "io.qameta.allure.espresso.AllureAndroidRunner
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.0'
implementation 'com.google.guava:guava:30.1.1-jre'
implementation 'org.seleniumhq.selenium:selenium-java:4.4.0'
implementation 'io.github.bonigarcia:webdrivermanager:5.3.0'
implementation 'io.qameta.allure:allure-junit4:2.19.0'
}
tasks.withType(Test) {
exclude '**/calltest/Summary.class'
}
Attached the copy of build.gradle file.
I have netbeans 12.4 and java 11 installed on fedora. I have created a Gradle multi project. It compiles fine but code completion isn't working
In Netbeans, have created I library named Facebook in tools>libraries. I then extracted classes.jar from Gradle cache file .aar packages. I renamed and added these to Facebook Library class path
I can't seem to be able to find the class path in my java files when I do
import com.facebook.*;
Netbeans says unable to find class path com.facebook.*;
What am I doing. wrong how can I make netbeans recognize my jar when I am coding like code completion
Project build.gradle
description = 'Example Project'
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.0")
}
}
allprojects {
group = 'com.example'
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Project settings.gradle
rootProject.name = 'example'
include ':app'
Module build.gradle
plugins {
id 'com.android.application'
}
description = 'app'
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId("com.example.app")
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation":"$projectDir/schemas".toString()]
}
}
}
buildTypes {
debug {
minifyEnabled false
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
annotationProcessor 'androidx.room:room-compiler:2.3.0'
implementation 'androidx.annotation:annotation:1.2.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.core:core:1.6.0'
implementation 'androidx.fragment:fragment:1.3.6'
implementation 'androidx.lifecycle:lifecycle-livedata:2.3.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel:2.3.1'
implementation 'androidx.navigation:navigation-fragment:2.3.5'
implementation 'androidx.navigation:navigation-ui:2.3.5'
implementation 'androidx.room:room-runtime:2.3.0'
implementation 'com.facebook.android:facebook-android-sdk:5.15.3'
implementation 'com.google.android.material:material:1.4.0'
testImplementation 'androidx.room:room-testing:2.3.0'
testImplementation 'junit:junit:4.13.2'
}
In the Projects window right-click on the name of the project that lacks library -> Properties ->
The Project Properties POP UP. In Categories tree select "Libraries" node ->
On the right side of the Project Properties window press "Add JAR/Folder" ->
And here Select jars you need.
You also can see my short Video How-To.
I am getting the following error in the Android Studio when "Gradle sync" is on action:
Could not GET 'https://jcenter.bintray.com/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.4.30/kotlin-stdlib-jdk8-1.4.30.pom'. Received status code 403 from server: Forbidden
Disable Gradle 'offline mode' and sync project
It downloads few files then stuck on the same filekotlin-stdlib-jdk8-1.4.30.pom and show the error above.
I have tried several solutions like here and here and none of them realy solve the problem.
And since I am only using Java why the Android studio should care about kotlin ,is there any thing i can do to avoid dealing with Kotlin?
this is the gradle>build.gradle file:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
//classpath "com.android.tools.build:gradle:4.1.3"
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:4.2.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and this is the app>src>build.gradle file:
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.myapplication_10"
minSdkVersion 29
targetSdkVersion 29
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 {
classpath 'com.android.tools.build:gradle:+'
classpath 'com.google.gms:google-services:4.2.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
403 Forbidden usually means you're connecting from a country under US sanctions (Iran for example). Try to clean project, clear Gradle cache, quit android studio, connect to a VPN to change the IP of your computer, open studio and sync/run. Also some services like Shecan or Begzar might help.
After I move to java 8, I get this error in app release, because of fabric crashlytics:
Could not determine the dependencies of task ':app:crashlyticsStoreDeobsRelease'.
> Task with path 'dexRelease' not found in project ':app'.
I'm using Android Studio 2.2, Gradle version 2.14.1, Android plugin version 2.2.0
The project run without any problem, but I can't generate signed apk!
I read this post Can't run project - Android Studio 2.0 Crashlytics issues and Could not determine the dependencies of task ':app:crashlyticsStoreDeobsDebug' if I enable the proguard but answer didn't helped me.
This is my gradle file:
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'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "..."
minSdkVersion 16
targetSdkVersion 22
versionCode 17
versionName "0.14.1"
jackOptions {
enabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
javaMaxHeapSize "3g"
}
signingConfigs {
release {
storeFile file("....jks")
storePassword "..."
keyAlias "..."
keyPassword "..."
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
shrinkResources true
debuggable true
signingConfig signingConfigs.release
}
debug{
debuggable true
//applicationIdSuffix ".debug"
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
//Material edit text
compile 'com.rengwuxian.materialedittext:library:2.1.4'
//Circle progress bar
compile 'com.github.castorflex.smoothprogressbar:library-circular:1.1.0'
//a divider for recyclerview
compile 'com.yqritc:recyclerview-flexibledivider:1.2.9'
//Field and method binding for Android views
compile 'com.jakewharton:butterknife:7.0.1'
//crash reporting and streamline solution for distributing apps
compile('com.crashlytics.sdk.android:crashlytics:2.6.3#aar') {
transitive = true;
}
//LeakCanary
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
compile('com.github.ozodrukh:CircularReveal:2.0.1#aar') {
transitive = true;
}
compile project(':core')
}
apply plugin: 'com.google.gms.google-services'
I check the fabric tools version from this link
https://s3.amazonaws.com/fabric-artifacts/public/io/fabric/tools/gradle/maven-metadata.xml
Then I used a lower version classpath 'io.fabric.tools:gradle:1.25.4'
I have copied every single step of Aviary setup guide. During Gradle build, it gives me this:
Error:Configuration with name 'default' not found.
Installation Guide:
Adobe Creative SDK Documentation
Aviary SDK | Android Documentation
Files :
settings.gradle:
include ':app'
build.gradle(Module: app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.adobe.logopros"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:design:22.2.1'
compile 'com.adobe.creativesdk.foundation:auth:0.7.329'
compile 'com.adobe.creativesdk:image:4.0.0'
}
With Gradle, setting up with Aviary is extremely simple. Follow this approach only if you do not plan on customizing the SDK. Otherwise, you will need to add the SDK as its own module in your project directory. See section 4.2 for an in-depth walkthrough of this.
To start, open the build.gradle file of your Application in Android Studio. Please note that this is different from the build.gradle file of your root project.
Make sure that in the repositories block, you have both Maven Central and Aviary's Maven repository. It should look something like this:
repositories {
mavenCentral()
jcenter()
mavenLocal()
maven {
name 'maven.aviary.com'
url uri("http://maven.aviary.com/repo/release")
}
}
In this same file, add the following to the dependencies block in order to build your project with the Aviary SDK:
compile 'com.aviary.android.feather.sdk:aviary-sdk:3.6.3'
Finally, within packagingOptions in the android block, add the following in order to prevent duplicate copying of these files:
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
Here is an example how the build.gradle file should look:
repositories {
mavenCentral()
jcenter()
mavenLocal()
maven {
name 'maven.aviary.com'
url uri("http://maven.aviary.com/repo/release")
}
}
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
minSdkVersion 10
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
packagingOptions {
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
}
}
dependencies {
compile 'com.aviary.android.feather.sdk:aviary-sdk:3.6.3'
}
(Note that the minSdkVersion is 10.)
(Quick sidenote: the Aviary SDK Documentation linked above is depricated.)
Update: instructions for version 0.9.7
The Creative SDK Image Editor (formerly known as Aviary) is now offered as a remote Maven repo. In this section are the updated instructions for configuring gradle.
In your Project build.gradle, add the code below (see the comments):
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
/* 1) Add the Gradle Retrolambda Plugin */
classpath 'me.tatarka:gradle-retrolambda:3.3.0-beta3'
}
}
allprojects {
repositories {
jcenter()
/* 2) Add mavenCentral */
mavenCentral()
/* 3) Add the Creative SDK Maven repo URL */
maven {
url 'https://repo.adobe.com/nexus/content/repositories/releases/'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
In your Module build.gradle, add the code below (see the comments):
apply plugin: 'com.android.application'
/* 1) Apply the Gradle Retrolambda Plugin */
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.adobe.gettingstarted"
minSdkVersion 16 // Minimum is 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
/* 2) Compile for Java 1.8 or greater */
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
/* 3) Exclude duplicate licenses */
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/DEPENDENCIES'
pickFirst 'AndroidManifest.xml'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
/* 4) Add the CSDK framework dependencies (Make sure these version numbers are correct) */
compile 'com.adobe.creativesdk.foundation:auth:0.9.7'
}
Details are available in the Creative SDK for Android Getting Started guide.
Old instructions for 0.7.329 and below
Your Module build.gradle looks fine. You will also need a Project build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
maven {
url "${project.rootDir}/creativesdk-repo/release" // Location of the CSDK repo
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The difference between the two gradle.build configurations, including the code above, is covered in this section the Creative SDK Getting Started guide for Android.