I'm trying to write code in buildSrc in Android project, but it allways notice me Unresolved reference: xxx, like this:
Although the compilation can pass, it is always inconvenient. I've tried restarting the IDE, Invalidate Caches, reinstalling the IDE, but it dosen't work, so how to solve this problem? Thank you!
/buildSrc/build.gradle.kts:
plugins {
java
`kotlin-dsl`
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
dependencies {
// https://mvnrepository.com/artifact/net.dongliu/apk-parser
implementation("net.dongliu:apk-parser:2.6.10")
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
/build.gradle.kts:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
val androidVer = "7.3.1"
id("com.android.application") version androidVer apply false
id("com.android.library") version androidVer apply false
val ktVer = "1.7.20"
id("org.jetbrains.kotlin.android") version ktVer apply false
}
Solution: File -> Repire IDE, the step of Reindex project can solve this problem.
Related
I have a KMM project that is working perfectly except Android Studio gives an error on every expect function/value in my project complaining the actual version of it doesn't exist for JVM.
The A in a yellow diamond to the side of it shows both the iOS and Android actual versions and the project builds/runs just fine.
I've double checked package names and it happens with every expect regardless of the package.
I've looked over my gradle build files and can't find anything weird when comparing them to a new KMM example project.
plugins {
kotlin("multiplatform")
kotlin("native.cocoapods")
id("com.android.library")
id("com.rickclephas.kmp.nativecoroutines") version "0.12.2-new-mm"
}
version = "1.0"
kotlin {
android()
iosX64()
iosArm64()
//iosSimulatorArm64() sure all ios dependencies support this target
cocoapods {
summary = "Some description for the Shared Module"
homepage = "Link to the Shared Module homepage"
ios.deploymentTarget = "15.0"
podfile = project.file("../iosApp/Podfile")
framework {
baseName = "shared"
}
}
sourceSets {
val ktorVersion = "2.0.2"
val commonMain by getting {
dependencies {
implementation("com.litclimbing:firebase-auth:+")
implementation("com.litclimbing:firebase-firestore:+")
implementation("com.litclimbing:buffer:+")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1")
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.3.2")
implementation("io.ktor:ktor-client-core:$ktorVersion")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val androidMain by getting {
dependencies {
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.4.1")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1")
implementation("io.ktor:ktor-client-okhttp:$ktorVersion")
}
}
val androidTest by getting
val iosX64Main by getting
val iosArm64Main by getting
//val iosSimulatorArm64Main by getting
val iosMain by creating {
dependsOn(commonMain)
iosX64Main.dependsOn(this)
iosArm64Main.dependsOn(this)
//iosSimulatorArm64Main.dependsOn(this)
dependencies {
implementation("io.ktor:ktor-client-darwin:$ktorVersion")
}
}
val iosX64Test by getting
val iosArm64Test by getting
//val iosSimulatorArm64Test by getting
val iosTest by creating {
dependsOn(commonTest)
iosX64Test.dependsOn(this)
iosArm64Test.dependsOn(this)
//iosSimulatorArm64Test.dependsOn(this)
}
}
sourceSets.all {
languageSettings.optIn("kotlin.RequiresOptIn")
languageSettings.optIn("kotlin.ExperimentalUnsignedTypes")
}
}
android {
compileSdk = 32
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdk = 29
targetSdk = 32
}
}
buildscript {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21")
classpath("com.android.tools.build:gradle:7.2.1")
classpath("com.google.gms:google-services:4.3.10")
classpath("com.google.firebase:firebase-crashlytics-gradle:2.9.0")
}
}
allprojects {
repositories {
google()
mavenLocal()
mavenCentral()
maven {
setUrl("https://jitpack.io")
}
maven {
setUrl("https://maven.pkg.jetbrains.space/public/p/kotlinx-coroutines/maven")
}
}
}
tasks.register("clean", Delete::class) {
delete(rootProject.buildDir)
}
I've even tried copying the gradle files to a new KMM project to see if it would break it and it didn't so I'm at a loss of where to even look.
Not really the solution I was looking for but it seems to be a bug in Android Studio/IntelliJ and not the gradle setup.
To fix it do the following.
Close Android Studio
Open your project folder in the file browser
Rename the .idea folder to .ideaBackup
Reopen the project
Assuming everything is now working, delete .ideaBackup
Enjoy your lack of random errors
I wanted to add JaCoCo to an existing Android Studio Project. In my settings.gradle I edited:
pluginManagement {
gradle.ext.kotlin_version = "1.6.0"
repositories {
google()
mavenCentral()
}
def versionsProp = new Properties()
versionsProp["myapp.version.level"] = "7.1.0-beta05"
def versionsPropFile = file("local.properties")
if (versionsPropFile.canRead()) {
versionsProp.load(new FileInputStream(versionsPropFile))
}
def levelVersion = versionsProp["myapp.version.level"]
plugins {
id("com.android.application") version "$levelVersion"
id("com.android.library") version "$levelVersion"
id("org.jetbrains.dokka") version "1.4.30"
id("org.jetbrains.kotlin.android") version "$gradle.ext.kotlin_version"
id("org.jacoco.core") version "0.8.7"
} }
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
mavenLocal()
} }
rootProject.name = "TestApp"
include ":app"
include ":mylib_1"
include ":mylib_2"
include ":docs"
Especially I added JaCoCo in plugins section. According to this medium article :
Now inside each module’s build.gradle file apply the newly created
jacoco.gradle as such: apply from: "$project.rootDir/jacoco.gradle"
But in my app modules build gradle (I've shortened away stuff commented there) I have follwing structure:
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}
android {
compileSdkVersion = 31
buildToolsVersion = "31.0.0"
defaultConfig {
applicationId = "org.example.myapp"
// minSdkVersion(21), targetSdkVersion(31) ..
}
// buildTypes, flavorOptions, compose options
// compile options, kotlinOptions, buildFeatures, packagingOptions, lintOptions
}
dependencies {
implementation(fileTree(include: ["*.jar"], dir: "libs"))
implementation("androidx.activity:activity-compose:$compose_activity_version")
implementation("androidx.appcompat:appcompat:$appcompat_version")
testImplementation("junit:junit:4.13.2")
implementation(project(":org_mylib_1"))
implementation(project(":org_mylib_2"))
}
So where or how am I supposed to add the apply from: "$project.rootDir/jacoco.gradle"?
Recently i started to work on a kotlin multiplatform project, i did not have any previous experience when i started, and i got the project with its base already created. The developer that create the project had the ideia to use the compose library on android development part.
Then he quit the job, and i started in it.
But i choose to not use compose because of the rush on deliver the application.
So the project gradle version is currently on 6.8 and android plugin on 7.0.0-alpha05
but i want to downgrade to stop to use the Android Studio on Canary version, and use on a stable version. But when i downgrade the gradle i am getting this error:
A problem occurred configuring project ':shared'.
> Failed to notify project evaluation listener.
> /Users/jhonata/Documents/Projetos/Aurea/quicktendr-mgmt/shared/src/main/AndroidManifest.xml (No such file or directory)
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':shared'.
at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:75)
at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:68)
at org.gradle.configuration.project.LifecycleProjectEvaluator.access$400(LifecycleProjectEvaluator.java:51)
at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.run(LifecycleProjectEvaluator.java:191)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
at ...
gradle properties:
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
shared gradle:
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin("multiplatform")
id("com.android.library")
id("kotlin-parcelize")
id("dev.icerock.mobile.multiplatform-resources")
kotlin("plugin.serialization")
}
android {
configurations {
create("androidTestApi")
create("androidTestDebugApi")
create("androidTestReleaseApi")
create("testApi")
create("testDebugApi")
create("testReleaseApi")
}
}
kotlin {
// jvm()
android()
ios {
binaries {
framework {
baseName = "shared"
when (val target = this.compilation.target.name) {
"iosX64" -> {
export(Deps.Decompose.iosX64)
}
"iosArm64" -> {
export(Deps.Decompose.iosArm64)
}
else -> error("Unsupported target: $target")
}
}
}
}
sourceSets {
val commonMain by getting {
dependencies {
api(Deps.Decompose.decompose)
api(Deps.coroutines)
implementation(Deps.ktxSerializationJson)
implementation(Deps.ktorCore)
implementation(Deps.ktorSerialization)
implementation(Deps.kissMeCommon)
implementation("ch.qos.logback:logback-classic:1.2.3")
implementation("dev.icerock.moko:mvvm-core:0.10.1")
implementation("dev.icerock.moko:mvvm-livedata:0.10.1")
api("dev.icerock.moko:resources:0.15.1")
api("dev.icerock.moko:mvvm:0.9.1")
implementation("io.ktor:ktor-client-logging:1.4.2")
implementation("io.ktor:ktor-client-auth:1.4.2")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
// val mobileMain by creating {
// dependsOn(commonMain)
// dependencies {
//
// }
// }
val androidMain by getting {
dependencies {
implementation(Deps.ktorAndroid)
implementation(Deps.kissMeAndroid)
}
}
val androidTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.13")
}
}
val iosMain by getting {
dependencies {
implementation(Deps.ktorIOS)
implementation(Deps.kissMeIOS)
}
}
val iosTest by getting
// val jvmMain by getting {
// dependencies {
// implementation("io.ktor:ktor-client-okhttp:1.4.2")
// }
// }
named("iosX64Main") {
dependencies {
api(Deps.Decompose.iosX64)
}
}
named("iosArm64Main") {
dependencies {
api(Deps.Decompose.iosArm64)
}
}
}
}
multiplatformResources {
multiplatformResourcesPackage = "com.quicktendr.mgmt" // required
iosBaseLocalizationRegion = "es" // optional, default "en"
}
android {
compileSdkVersion(29)
sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
defaultConfig {
minSdkVersion(24)
targetSdkVersion(29)
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}
val packForXcode by tasks.creating(Sync::class) {
group = "build"
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
val framework =
kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
val targetDir = File(buildDir, "xcode-frameworks")
from({ framework.outputDirectory })
into(targetDir)
}
tasks.getByName("build").dependsOn(packForXcode)
gradle:
buildscript {
repositories {
gradlePluginPortal()
jcenter()
google()
mavenCentral()
maven("https://kotlin.bintray.com/kotlinx")
maven("https://dl.bintray.com/jetbrains/kotlin-native-dependencies")
maven("https://dl.bintray.com/kotlin/kotlin-dev")
maven("https://dl.bintray.com/icerockdev/plugins")
}
dependencies {
val kotlinVersion = "1.4.31"
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
classpath("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
classpath("com.android.tools.build:gradle:4.2.1")
classpath("com.github.jengelman.gradle.plugins:shadow:5.2.0")
classpath("dev.icerock.moko:resources-generator:0.15.1")
classpath("com.google.gms:google-services:4.3.5")
classpath("com.google.firebase:firebase-crashlytics-gradle:2.5.2")
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven("https://dl.bintray.com/arkivanov/maven")
maven("https://dl.bintray.com/icerockdev/moko")
maven("https://dl.bintray.com/netguru/maven/")
maven("https://repo.repsy.io/mvn/chrynan/public")
maven("https://jitpack.io")
}
}
If you just want to downgrade gradle, you can downgrade gradle in the gradle properties file which you posted.
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
You would need to set this to the latest version supported by Android Studio 4.2.1. There are also compatibility considerations with the Android gradle plugin. You can see a compatibility matrix for that here:
https://developer.android.com/studio/releases/gradle-plugin#4-2-0
Please be aware that if your project was using things like compose which relied on particular versions of AGP/Gradle, you might need to rewrite those pieces. It is okay to use the canary versions of android studio or recent versions of intellij - unless you are hitting some issue. You can use compose and old view classes together using AndroidView
https://developer.android.com/jetpack/compose/interop/interop-apis#views-in-compose
Im trying to integrate a "module"-project generated by swagger-codegen, into my Android project.
Haven't worked that much with gradle before and the swagger-codegen creates a quite messy build.gradle from my point of view.
I have a hard time finding documentation on how to do this. And I feel a bit lost.
I used this method described in the FAQ
mvn clean package
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://petstore.swagger.io/v2/swagger.json \
-l java --library=okhttp-gson \
-o /var/tmp/java/okhttp-gson/
So fare I tried to copy the source from the project that was generated by swagger-codegen and merge the two gradle build files. I removed the Junit tests because I couldn't get the Junit dependency working (Implementing Swagger-codegen project - Error:(23, 17) Failed to resolve: junit:junit:4.12). But then I got stuck with some conflict between the plugins?
The 'java' plugin has been applied, but it is not compatible with the Android plugins.
Here's the build.gradle:
import static jdk.nashorn.internal.runtime.regexp.joni.ApplyCaseFold.apply
apply plugin: 'idea'
apply plugin: 'eclipse'
group = 'io.swagger'
version = '1.0.0'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// classpath 'com.android.tools.build:gradle:1.5.+'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
}
}
repositories {
jcenter()
maven { url 'http://repo1.maven.org/maven2' }
}
if(hasProperty('target') && target == 'android') {
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
// Rename the aar correctly
libraryVariants.all { variant ->
variant.outputs.each { output ->
def outputFile = output.outputFile
if (outputFile != null && outputFile.name.endsWith('.aar')) {
def fileName = "\u0024{project.name}- \u0024{variant.baseName}-\u0024{version}.aar"
output.outputFile = new File(outputFile.parent, fileName)
}
}
}
dependencies {
provided 'javax.annotation:jsr250-api:1.0'
}
}
afterEvaluate {
android.libraryVariants.all { variant ->
def task = project.tasks.create "jar${variant.name.capitalize()}", Jar
task.description = "Create jar artifact for ${variant.name}"
task.dependsOn variant.javaCompile
task.from variant.javaCompile.destinationDir
task.destinationDir = project.file("${project.buildDir}/outputs/jar")
task.archiveName = "${project.name}-${variant.baseName}-${version}.jar"
artifacts.add('archives', task);
}
}
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
artifacts {
archives sourcesJar
}
} else {
apply plugin: 'java'
apply plugin: 'maven'
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
install {
repositories.mavenInstaller {
pom.artifactId = 'XxxxXxxx'
}
}
task execute(type:JavaExec) {
main = System.getProperty('mainClass')
classpath = sourceSets.main.runtimeClasspath
}
}
dependencies {
compile 'io.swagger:swagger-annotations:1.5.8'
compile 'com.squareup.okhttp:okhttp:2.7.5'
compile 'com.squareup.okhttp:logging-interceptor:2.7.5'
compile 'com.google.code.gson:gson:2.6.2'
compile 'joda-time:joda-time:2.9.3'
// testCompile 'junit:junit:4.12'
}
Am I doing something complete wrong here? What is the correct way to implement swagger-codegen code into my project?
The swift way to import it was to compile the swagger generated project then copy the .jar file to my android project and add its as a library.
I have a hard time finding documentation on how to do this. And I feel a bit lost.
You could clone the Android swagger-codegen example.
(which does use Junit, so I'm not sure what error you got)
Unless that's what you mean by
So far I tried to copy the source and merge the two gradle build files
To which, I ask, what two Gradle files? It looks like you merged an Android Gradle file with a Java Gradle file, which seems to causing more issues because you are getting...
The 'java' plugin has been applied, but it is not compatible with the Android plugins.
Which seems pretty self explanatory when you have this line
apply plugin: 'java'
It's not too clear what you are trying to do here other than check the build target
if(hasProperty('target') && target == 'android')
I'm trying to add native debugging to a project that is an Android Studio NDK project. In the past I just used gradle to kick off a shell script, which built the NDK lib. Now I'm trying to move to use the gradle-experimental plugin.
I've scoured the net for what little info there is, (mostly here, Android Tools Site - Gradle Experimental), about using gradle-experimental with the NDK and I've put together this build.gradle file which is using the preview NDK support for doing the NDK build inline with the Java build.
After finally getting this together from bits-and-pieces of info, I managed to get the NDK portion building, but now it fails to include the httpmime-4.4-beta1.jar file that is clearly included in the dependencies, and I've tried many different permutations of it such as in:
compile files("libs/httpmime-4.4.jar")
But regardless, the errors for the missing symbols from the Jar file still appear.
build.gradle source
apply plugin: 'com.android.model.application'
String APP_PACKAGE_NAME = 'com.obfuscated.app',
VERSION_NAME = '3.0',
TOOLS_VERSION = '23.0.2'
int VERSION_CODE = 15,
MIN_SDK_VERSION = 13,
TARGET_SDK_VERSION = 19,
COMPILE_SDK_VERSION = 23
model {
repositories {
libs(PrebuiltLibraries) {
// prebuilt binaries mirroring Android.mk
libstuff {
headers.srcDirs.add(file("jni/stuff/include/stuff"))
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file("jni/stuff/lib/libstuff.so")
}
}
// ...several more of these actually exist in build.gradle and are working
cares {
headers.srcDirs.add(file("jni/c-ares/include"))
binaries.withType(SharedLibraryBinary) {
// StaticLibraryBinary and staticLibraryFile doesnt work despite sample code, at least not for com.android.tools.build:gradle-experimental:0.6.0-alpha5, this builds even though its a static-lib
sharedLibraryFile = file("jni/c-ares/lib/libcaresARM.a")
}
}
}
}
android {
compileSdkVersion = COMPILE_SDK_VERSION
buildToolsVersion = TOOLS_VERSION
defaultConfig.with {
applicationId = APP_PACKAGE_NAME
minSdkVersion.apiLevel = MIN_SDK_VERSION
targetSdkVersion.apiLevel = TARGET_SDK_VERSION
versionCode = VERSION_CODE
versionName = VERSION_NAME
buildConfigFields {
create() {
type "int"
name "VALUE"
value "1"
}
}
compileOptions.with {
sourceCompatibility = JavaVersion.VERSION_1_7
targetCompatibility = JavaVersion.VERSION_1_7
}
}
signingConfigs {
create("appRelease") {
storeFile file('sign.jks')
storePassword '...'
keyAlias '...'
keyPassword '...'
storeType "jks"
}
}
} // end android
android.lintOptions {
abortOnError = false
}
android.packagingOptions {
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
android.ndk {
moduleName = "native"
toolchain "clang"
toolchainVersion "3.5"
platformVersion = MIN_SDK_VERSION
ldLibs.addAll('atomic', 'android', 'log', 'OpenSLES')
abiFilters.addAll(["armeabi", "armeabi-v7a"])
CFlags.addAll(["-mfloat-abi=softfp", "-mfpu=neon", "-O3", "-DCARES_STATICLIB", "-Wno-c++11-long-long"])
cppFlags.addAll(["-I${file("jni")}".toString(),
"-I${file("jni/c-ares/include")}".toString(),
"-I${file("jni/coffeecatch")}".toString()])
stl = "stlport_shared"
}
android.sources {
main {
jniLibs {
dependencies {
}
}
jni {
dependencies {
library "libstuff"
library "cares"
// ...
}
source {
srcDir "jni"
}
}
// java {
// dependencies {
// compile files("libs/httpmime-4.4-beta1.jar")
// compile files("libs/FlurryAnalytics-5.1.0.jar")
// }
// }
}
}
android.buildTypes {
debug {
ndk.with {
debuggable = true
}
}
release {
minifyEnabled = false
ndk.with {
debuggable = true
}
}
}
android.productFlavors {
create("arm") {
ndk.with {
abiFilters.add("armeabi-v7a")
ldLibs.addAll([file("jni/stuff/lib/libstuff.so").toString(),
file("jni/c-ares/lib/libcaresARM.a").toString()])
}
}
create("fat") {
// compile and package all supported ABI
}
}
} // end model
repositories {
mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.+'
compile 'com.android.support:appcompat-v7:23.+'
compile 'com.android.support:support-v13:23.+'
compile 'com.android.support:support-annotations:23.+'
compile 'com.squareup:otto:1.3.8'
compile 'com.github.machinarius:preferencefragment:0.1.1'
compile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
compile 'com.fasterxml.jackson.core:jackson-core:2.5.+'
compile 'com.fasterxml.jackson.core:jackson-annotations:2.5.+'
compile 'com.fasterxml.jackson.core:jackson-databind:2.5.+'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.google.guava:guava:19.0'
}
allprojects {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked"
}
}
Out of frustration, I switched back to the non-experimental branch, and even with the old build.gradle file it is now failing to find that same jar file. So is it a problem with Android Studio 2.0 Preview 6?
Has anyone else experienced this, or have a solution for it? It would be so convenient to finally have NDK debugging work right in Android Studio, and if it weren't for this last hurdle, I think I would be there.
Short of re-writing the code that depends on that jar file, I am at a loss for what else to try. I am also open to suggestions for the format of my build.gradle file above, since the documentation for these new features is very sparse still, and some of the samples seem to be already out-of-date with regard to the proper syntax.
WHAT AM I MISSING?
You can see that the C and Cpp (mobile:compileNativeArmeabiDebugArmSharedLibraryNativeMainCpp), steps are happening just fine, but then the Javac fails. This jar file approach has worked fine for the past 2 years or so for the http-mime lib from apache, so I don't understand why suddenly this is a problem.
:mobile:mergeArmDebugAndroidTestAssets
:mobile:generateArmDebugAndroidTestResValues UP-TO-DATE
:mobile:generateArmDebugAndroidTestResources
:mobile:mergeArmDebugAndroidTestResources
:mobile:processArmDebugAndroidTestResources
:mobile:generateArmDebugAndroidTestSources
:mobile:copyArmeabi-v7aDebugArmSharedLibraryStlSo
:mobile:compileNativeArmeabi-v7aDebugArmSharedLibraryNativeMainC
:mobile:compileNativeArmeabi-v7aDebugArmSharedLibraryNativeMainCpp
:mobile:linkNativeArmeabi-v7aDebugArmSharedLibrary
:mobile:nativeArmeabi-v7aDebugArmSharedLibrary
:mobile:stripSymbolsArmeabi-v7aDebugArmSharedLibrary
:mobile:ndkBuildArmeabi-v7aDebugArmSharedLibrary
:mobile:ndkBuildArmeabi-v7aDebugArmStaticLibrary UP-TO-DATE
:mobile:copyArmeabiDebugArmSharedLibraryStlSo
:mobile:compileNativeArmeabiDebugArmSharedLibraryNativeMainC
:mobile:compileNativeArmeabiDebugArmSharedLibraryNativeMainCpp
:mobile:linkNativeArmeabiDebugArmSharedLibrary
:mobile:nativeArmeabiDebugArmSharedLibrary
:mobile:stripSymbolsArmeabiDebugArmSharedLibrary
:mobile:ndkBuildArmeabiDebugArmSharedLibrary
:mobile:ndkBuildArmeabiDebugArmStaticLibrary UP-TO-DATE
:mobile:processAndroidArmDebugMainJniLibs UP-TO-DATE
:mobile:androidArmDebug
:mobile:compileArmDebugJavaWithJavac
:mobile:compileArmDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
Yes, I know the apache libs are deprecated, but this is legacy code that should work despite that fact, and will be updated in the future.
A general way to do the include you're looking for is this in the dependencies.
compile fileTree(dir: 'libs', include: ['*.jar'])
However, I'm not certain that will solve this particular problem. I've always had success with putting the jar in the libs directory at the top of the directory structure.
If you need to have the jar in a different location, then this works for me:
repositories {
flatDir {
dirs '<relativePathToJar>'
}
}
model { ... }
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}