I've changed my PC then I installed Android Studio Latest Version. On my previous PC, everything is worked well. On my new PC, all my androidx import is RED, and cannot build my project. Kotlin scoped functions also don't work. Don't know launch, viewModels(), let, apply, run, etc.. I've already cleared .gradle and cache files in my directory. I am stuck in this for about one week. Can someone help me? Please!!!! The following are my problems.
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.galaxy_techno.seller.domain.AppRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.delay
import javax.inject.Inject
my gradle files are...
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext{
tools_version = '7.0.4'
plugin_version = '1.6.10'
hilt_version = '2.40.5'
navigation_version = '2.3.5'
}
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}
dependencies {
classpath "com.android.tools.build:gradle:$tools_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$plugin_version"
classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigation_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Project gradle is
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id 'androidx.navigation.safeargs.kotlin'
id 'kotlin-parcelize'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.klt_clean_architecture_sample"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
multiDexEnabled true
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
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures.viewBinding = true
}
dependencies {
//splash screen
implementation 'androidx.core:core-splashscreen:1.0.0-beta01'
def core_ktx = '1.7.0'
implementation "androidx.core:core-ktx:$core_ktx"
def viewModel_ktx = '2.4.0'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$viewModel_ktx"
def activity_ktx = '1.4.0'
implementation "androidx.activity:activity-ktx:$activity_ktx"
def fragment_ktx = '1.4.0'
implementation "androidx.fragment:fragment-ktx:$fragment_ktx"
def lifecycle_ktx = '2.4.0'
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_ktx"
def livedata_ktx = '2.4.0'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$livedata_ktx"
def room_ktx = '2.4.1'
implementation "androidx.room:room-ktx:$room_ktx"
def navigation_ktx = '2.3.5'
implementation "androidx.navigation:navigation-runtime-ktx:$navigation_ktx"
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_ktx"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_ktx"
def workManager_ktx = '2.7.1'
implementation "androidx.work:work-runtime-ktx:$workManager_ktx"
def collection_ktx = '1.2.0'
implementation "androidx.collection:collection-ktx:$collection_ktx"
def palette_ktx = '1.0.0'
implementation "androidx.palette:palette-ktx:$palette_ktx"
def retrofit_v = '2.9.0'
implementation "com.squareup.retrofit2:retrofit:$retrofit_v"
def retro_coroutines = '0.9.2'
implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:$retro_coroutines"
def okhttp_v = '5.0.0-alpha.3'
implementation "com.squareup.okhttp3:okhttp:$okhttp_v"
def locale_v = '1.0.8'
implementation "com.localebro:okhttpprofiler:$locale_v"
def logging_v = '5.0.0-alpha.3'
implementation "com.squareup.okhttp3:logging-interceptor:$logging_v"
def gson_v = '2.9.0'
implementation "com.squareup.retrofit2:converter-gson:$gson_v"
def room_v = '2.4.1'
implementation "androidx.room:room-runtime:$room_v"
kapt "androidx.room:room-compiler:$room_v"
def datastore_v = '1.0.0'
implementation "androidx.datastore:datastore-preferences:$datastore_v"
def coroutines_v = '1.6.0-native-mt'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_v"
def timber_v = '5.0.1'
implementation "com.jakewharton.timber:timber:$timber_v"
def glide_v = '4.12.0'
implementation "com.github.bumptech.glide:glide:$glide_v"
def hilt_v = '2.40.5'
implementation "com.google.dagger:hilt-android:$hilt_v"
kapt "com.google.dagger:hilt-compiler:$hilt_v"
def ui_version = '1.5.0'
def appcompat_version = '1.4.1'
implementation "androidx.appcompat:appcompat:$appcompat_version"
implementation "com.google.android.material:material:$ui_version"
def constraint_v = '2.1.3'
implementation "androidx.constraintlayout:constraintlayout:$constraint_v"
def multidex_v = '2.0.1'
implementation "androidx.multidex:multidex:$multidex_v"
//dynamic animation
implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Related
I'm getting this error
What went wrong:
A problem occurred evaluating root project 'android'.
A problem occurred configuring project ':app'.
Could not create task ':app:packLibsflutterBuildDebug'.
> No signature of method: org.gradle.api.tasks.bundling.Jar.destinationDir() is applicable for argument types: (File) values: [/Users/amjadkhoulani/Downloads/food_app12amjad/build/app/intermediates/flutter/debug]
build.gradle
buildscript {
ext {
kotlin_version = '1.5.0'
}
repositories {
google()
jcenter()
gradlePluginPortal()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.10, 0.99.99]'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
defaultConfig {
// Required by the Flutter WebView plugin.
minSdkVersion 21
}
compileSdkVersion rootProject.ext.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.food_app"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion 20
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
manifestPlaceholders = [applicationName: "android.app.Application"]
}
debug {
manifestPlaceholders = [applicationName: "android.app.Application"]
}
build{
manifestPlaceholders = [applicationName: "android.app.Application"]
}
}
}
app/build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
android {
compileSdk 33
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.example.abc.test"
minSdkVersion 21
targetSdkVersion 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
apply plugin: 'kotlin-android'
apply plugin: "kotlin-android-extensions"
androidExtensions {
experimental = true
}
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
flutter {
source '../..'
}
dependencies {
implementation platform('com.google.firebase:firebase-bom:26.3.0')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.onesignal:OneSignal:[4.0.0, 4.99.99]'
implementation 'com.google.android.material:material:33'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
......................
This can happen if your gradle dependencies are out of date or out of sync.
android/build.gradle
Find the most recent, stable version of com.android.tools.build from here and update your dependencies:
dependencies {
...
classpath 'com.android.tools.build:gradle:7.4.1'
}
android/gradle/wrapper/gradle-wrapper.properties
Find the most recent stable version of Gradle from here and update the distribution URL.
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
i found some broke problem here, this is new project with default sample code I haven't do anything with the code then my android studio looks like in the image
I've try a lot of things including uninstalling android studio and re-installing this android studio, but I still found the same problem
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdk 31
defaultConfig {
applicationId "id.rizki.nidelist"
minSdk 23
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
useIR = true
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion '1.5.21'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'
implementation 'androidx.activity:activity-compose:1.4.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
}
You're not using the correct dependency versions. Most importantly, you are not using the correct version of Kotlin or Java:
In your project grade file use this:
buildscript {
ext {
compose_version = '1.1.0-beta01'
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31'
}
}
In your app's gradle file:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'org.jetbrains.kotlin.plugin.serialization' version '1.5.10'
}
apply from: 'codeinc.gradle'
android {
compileSdkVersion 31
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.example.myapp"
minSdkVersion 21
targetSdkVersion 31
versionName "1.0"
//def yourVersionCode = getIncrementedVersionCode()
versionCode 1
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
useIR = true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion '1.5.31'
}
}
dependencies {
def lifecycle_version = '2.4.0'
def activity_version = '1.4.0'
def retrofit_version = "2.9.0"
def paging_version = '3.1.0-beta01'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0-rc01'
implementation 'com.google.android.material:material:1.5.0-alpha05'
implementation "androidx.activity:activity-ktx:$activity_version"
implementation "androidx.activity:activity-compose:$activity_version"
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.material:material-icons-extended:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
implementation "androidx.compose.foundation:foundation:$compose_version"
implementation "androidx.constraintlayout:constraintlayout-compose:1.0.0-rc01"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0'
}
I'm writing a test suite with mockwebserver. I entered all of the dependencies from the official github page. Every time I try to run the test I receive Unresolved reference: mockwebserver
There's no option to import. The lettering isn't red on the import. Android Studio doesn't prompt anything. There are no other errors aside from ones related to the unresolved reference.
Screenshot:
build.gradle
plugins {
id 'com.android.application'
id 'kotlin-android'
id("org.jetbrains.kotlin.android.extensions")
}
android {
compileSdk 31
useLibrary("android.test.runner")
useLibrary("android.test.base")
useLibrary("android.test.mock")
defaultConfig {
applicationId "com.example.moviespotter"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
buildFeatures {
viewBinding = true
compose true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
kotlinCompilerVersion '1.5.21'
}
kotlinOptions {
jvmTarget = '1.8'
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = '1.8'
}
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.activity:activity-compose:1.3.1'
implementation 'androidx.test.espresso:espresso-idling-resource:3.1.1'
testImplementation 'junit:junit:4.13'
testImplementation 'com.squareup.okhttp3:mockwebserver3:5.0.0-alpha.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'androidx.test:runner:1.4.0'
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation 'com.squareup.retrofit2:retrofit:2.7.0'
implementation 'com.squareup.retrofit2:converter-gson:2.7.0'
implementation 'com.squareup.okhttp3:okhttp:4.3.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.github.bumptech.glide:glide:4.10.0' //Glide
implementation "androidx.fragment:fragment-ktx:$fragment_version"
implementation "androidx.fragment:fragment-ktx:$fragment_version"
implementation "io.coil-kt:coil-compose:1.3.1"
annotationProcessor 'com.github.bumptech.glide:compiler:4.10.0'
androidTestImplementation 'com.jakewharton.espresso:okhttp3-idling-resource:1.0.0'
}
Since this is in androidTest, it should be
androidTestImplementation 'com.squareup.okhttp3:mockwebserver3:5.0.0-alpha.2'
Also mixing 5.0.0-alpha.2 and 4.3.1 is a world of hurt.
I found the culprit.
When adding the dependency to the build.gradle file it should read implementation.
Change From:
testImplementation 'com.squareup.okhttp3:mockwebserver3:5.0.0-alpha.2'
To:
implementation 'com.squareup.okhttp3:mockwebserver3:5.0.0-alpha.2'
I'm facing an odd problem with Android Studio and Artifactory. I want to publish a module from Android Studio. The problem being, the build info is published just fine but the artifacts are not published.
build.gradle
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.5.4"
}
}
allprojects {
apply plugin: "com.jfrog.artifactory"
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
artifactory {
contextUrl = "${artifactory_contextUrl}"
publish {
repository {
repoKey = 'libs-release-local'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
resolve {
repository {
repoKey = 'libs-release'
username = "${artifactory_user}"
password = "${artifactory_password}"
maven = true
}
}
}
module/build.gradle
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
def packageName = 'x.x'
def libraryVersion = 'v1.0.0'
android {
compileSdkVersion 26
defaultConfig {
minSdkVersion 21
targetSdkVersion 26
versionCode 10000
versionName libraryVersion
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
publishing {
publications {
aar(MavenPublication) {
groupId packageName
version = libraryVersion
artifactId "y"
artifact("$buildDir/outputs/aar/$archivesBaseName-release.aar")
}
}
}
artifactory {
publish {
defaults {
publications('aar')
publishArtifacts = true
publishBuildInfo = false
publishPom = true
publishIvy = false
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.squareup.okhttp3:okhttp:3.8.1'
implementation 'com.squareup.okhttp3:logging-interceptor:3.8.1'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
When I run ./gradlew assembleRelease artifactoryPublish from the terminal, I always get the following output:
> Task :minecommon:artifactoryPublish
Deploying build descriptor to: https://artifactory-domain/artifactory/api/build
Build successfully deployed. Browse it in Artifactory under https://artifactory-domain/artifactory/webapp/builds/project-name/1509633107114
BUILD SUCCESSFUL in 2s
26 actionable tasks: 1 executed, 25 up-to-date
I can find the build in the "Build Browser" of my Artifactory.
Is there something wrong with my configuration? How can I make gradle publish my artifacts?
I've tries every article I could find on this issue to no resolve.
I am trying to get tensorflow in working android, kinda out of default project folder. I modified my build.gradle, but obviously I miss something, as my app crashes on runtime complying about unavailabiltity of native libraries. I have spent good few hours tring to solve this, but to no avail. Could someone help, please?
Basically, i compared .so file in APK produced by working tf demo and my .so, and they are different. So I suppose must me somewhere in my script...
def bazel_location = '/usr/local/bin/bazel'
def tf_location = '/home/poborak/SW/tensorflow-master'
def cpuType = 'armeabi-v7a'
def nativeDir = 'src/main/jniLibs/' + cpuType
project.buildDir = 'gradleBuild'
getProject().setBuildDir('gradleBuild')
buildscript {
System.properties['com.android.build.gradle.overrideVersionCheck'] = 'true'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
}
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "bazinac.aplikacenahouby"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
sourceSets {
main {
manifest.srcFile 'src/main/AndroidManifest.xml'
java.srcDirs = ['src/main/java', tf_location+'/tensorflow/contrib/android/java']
resources.srcDirs = ['src/main/java']
aidl.srcDirs = ['src/main/java']
renderscript.srcDirs = ['src/main/java']
res.srcDirs = ['src/main/res']
assets.srcDirs = ['src/main/assets']
jniLibs.srcDirs = ['src/main/jniLibs']
jni.srcDirs = []
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
}
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:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
testCompile 'junit:junit:4.12'
compile 'org.apache.commons:commons-io:1.3.2'
}
task buildNative(type:Exec) {
workingDir tf_location
commandLine bazel_location, 'build', '-c', 'opt', \
'tensorflow/examples/android:tensorflow_native_libs', \
'--crosstool_top=//external:android/crosstool', \
'--cpu=' + cpuType, \
'--host_crosstool_top=#bazel_tools//tools/cpp:toolchain'
}
task copyNativeLibs(type: Copy) {
from(tf_location+'bazel-bin/tensorflow/examples/android') { include '**/*.so' }
into nativeDir
duplicatesStrategy = 'include'
}
copyNativeLibs.dependsOn buildNative
assemble.dependsOn copyNativeLibs
Finally I have found workaround. It is to downgrade Gradle to 2.14.xx and Android Plugin Version 2.1.3. Then I have appended assembleDebug.dependsOn copyNativeLibs and it works now. Still I would be interested in better solution of course. (AssembleDebug property is not recognized in newer APV.