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
Related
I want to add the following library to the Gradle build of my project. The library that I want to add is : signal-protocol-java-2.8.1.jar that I have downloaded. How can I add it in the Gradle build, so that I import the classes included in the .jar it in the java classes that I am developing ?
Here is my build.gradle file :
buildscript {
repositories {
google()
mavenCentral()
jcenter {
content {
includeVersion 'org.jetbrains.trove4j', 'trove4j', '20160824'
includeGroupByRegex "com\\.archinamon.*"
}
}
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.1'
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.14'
classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha09"
}
}
ext {
BUILD_TOOL_VERSION = '30.0.2'
COMPILE_SDK = 30
TARGET_SDK = 30
MINIMUM_SDK = 19
JAVA_VERSION = JavaVersion.VERSION_1_8
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
}
allprojects {
repositories {
google()
jcenter()
}
}
subprojects {
ext.lib_signal_service_version_number = "2.15.3"
ext.lib_signal_service_group_info = "org.whispersystems"
ext.lib_signal_metadata_version = "0.1.2"
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
}
task qa {
group 'Verification'
description 'Quality Assurance. Run before pushing.'
dependsOn ':Signal-Android:testPlayProdReleaseUnitTest',
':Signal-Android:lintPlayProdRelease',
':libsignal-service:test',
':Signal-Android:assemblePlayProdDebug'
}
You have to edit your module-level build.gradle (the one you've posted is project-level). It's typically in the "app" folder of your project. Find there dependencies block and add this line:
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
...
}
Then create a folder "libs" near this gradle file and put your .jar library there. Sync the project with Gradle.
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()
}
I want to add Firebase Auth functionality to my Unity Android plugin, so
I followed this guide and added
apply plugin: 'com.google.gms.google-services'
to app's build.gradle file. But sync started to fail with
Error:(40, 0) Could not get unknown property 'LibraryVariants' for object of type com.android.build.gradle.LibraryExtension.
Here is a complete build.gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion '25.0.3'
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
project.archivesBaseName = "AndroidPlugin"
versionCode 1
versionName "1.0"
}
lintOptions {
abortOnError false
}
libraryVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('release.aar')) {
def fileName = "${archivesBaseName}.aar"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
}
dependencies {
provided fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile "com.android.support:exifinterface:25.3.1"
compile 'com.facebook.android:account-kit-sdk:4.+'
compile 'com.google.firebase:firebase-auth:11.0.4'
}
apply plugin: 'com.google.gms.google-services'
Project build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
You try add to project build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
i am integrating "Strip" payment method in my app but when i add the stripe dependence compile 'com.stripe:stripe-android:1.0.3' also try compile 'com.stripe:stripe-android:+' an error occur that is
i see many answer for realm Re-linker like using
compile 'com.getkeepsafe.relinker:relinker:1.2.1'
Compile 'io.reactivex:rxjava:1.1.0' but the problem is still exist
this is my Realm application class
public class WifiExploreApplication extends Application {
#Override
public void onCreate(){
super.onCreate();
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder(this)
.name("com.holygon.zaingz.alu").build();
Realm.setDefaultConfiguration(realmConfiguration)
}
}
this is my gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 'Google Apis:Google Apis:23'
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.wifiexplorer"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
multiDexEnabled true
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
repositories {
maven { url "https://jitpack.io" }
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.github.sembozdemir:ViewPagerArrowIndicator:1.0.0'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.android.support:multidex:1.0.0'
compile "com.android.support:support-v4:23.0.0"
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.getkeepsafe.relinker:relinker:1.2.1'
compile 'com.stripe:stripe-android:1.0.3'
}
dependencies {
repositories {
mavenCentral()
}
compile 'com.sothree.slidinguppanel:library:3.3.0'
}
allprojects {
repositories {
maven { url "https://jitpack.io" }
}
}
apply plugin: 'realm-android'
and
// 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.1.0'
classpath "io.realm:realm-gradle-plugin:0.88.2"
// 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
}
before using stripe all the things going well but when i use strip it will show error
any suggestion will appreciate able..
You're using the AAR Gradle Plugin version of Realm (as in 0.88.0+, but an outdated one, considering the latest is 1.1.0) but you're never actually calling apply plugin: 'realm-android' in your build.gradle file.
You're also missing this from your application class
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
Oh by the way, you probably should use modularized version of Google Play Services so that you wouldn't even need Multi-Dex in the first place.
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/