android studio 3.0 Canary 1 : project refresh failed - android

I tried to load my project in this new Android Studio 3.0 Canary 1.
It was running perfectly in my previous Android Studio Version 2.4 preview 7
This is the error I am facing:
Error:Could not resolve all dependencies for configuration ':sample:devCompileClasspath'.
Project :sample declares a dependency from configuration 'devCompile' to configuration 'dev' which is not declared in the descriptor for project :library.
My gradle configs are as below:
Project Level Build Gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
classpath 'com.google.gms:google-services:3.0.0'
// 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
}
Library Module Gradle:
apply plugin: 'com.android.library'
apply plugin: 'checkstyle'
android {
publishNonDefault true
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
minSdkVersion 19
targetSdkVersion 25
versionName project.VERSION_NAME
versionCode project.VERSION_CODE.toInteger()
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'AUTHORS'
exclude 'NOTICE'
}
buildTypes {
debug {
debuggable true
}
dev.initWith(buildTypes.debug)
staging.initWith(buildTypes.debug)
release {
minifyEnabled false
shrinkResources false
}
}
}
repositories {
flatDir {
dirs 'libs'
}
mavenLocal()
jcenter()
}
def ANDROID_SUPPORT_VERSION = "25.3.1"
def OK_HTTP3_VERSION = "3.6.0"
def GLIDE_VERSION = "3.7.0"
def GSON_VERSION = "2.8.0"
def AWS_KINESIS_VERSION = "2.4.2"
def PLAY_SERVICE_VERSION = "10.2.4"
dependencies {
compile(name: 'library-release', ext: 'aar')
compile "com.android.support:appcompat-v7:$ANDROID_SUPPORT_VERSION"
compile "com.android.support:design:$ANDROID_SUPPORT_VERSION"
compile "com.android.support:cardview-v7:$ANDROID_SUPPORT_VERSION"
compile "com.squareup.okhttp3:okhttp:$OK_HTTP3_VERSION"
compile "com.squareup.okhttp3:okhttp-urlconnection:$OK_HTTP3_VERSION"
compile "com.squareup.okhttp3:logging-interceptor:$OK_HTTP3_VERSION"
compile "com.google.code.gson:gson:$GSON_VERSION"
compile "com.google.firebase:firebase-messaging:$PLAY_SERVICE_VERSION"
compile "com.google.android.gms:play-services-location:$PLAY_SERVICE_VERSION"
compile "com.github.bumptech.glide:glide:$GLIDE_VERSION"
checkstyle('com.puppycrawl.tools:checkstyle:7.6.1')
compile "com.amazonaws:aws-android-sdk-kinesis:$AWS_KINESIS_VERSION"
}
apply plugin: 'com.google.gms.google-services'
task checkstyle(type: Checkstyle) {
showViolations = true
configFile file("config/checkstyle/checkstyle.xml")
description 'applies the checkstyle config to the java files'
source 'src/main/java'
include '**/*.java'
exclude '**/gen/**'
// empty classpath
classpath = files()
}
preBuild.dependsOn('checkstyle')
App Module Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.sample.and"
minSdkVersion 19
targetSdkVersion 25
versionName project.VERSION_NAME
versionCode project.VERSION_CODE.toInteger()
android.defaultConfig.vectorDrawables.useSupportLibrary = true
}
buildTypes {
debug {
debuggable true
minifyEnabled false
shrinkResources false
}
dev.initWith(buildTypes.debug)
dev {
applicationIdSuffix ".dev"
}
staging.initWith(buildTypes.debug)
staging {
applicationIdSuffix ".staging"
}
release {
shrinkResources false
minifyEnabled false
}
}
}
repositories {
flatDir{
dirs '../library/libs'
}
mavenLocal()
jcenter()
}
configurations {
releaseCompile
stagingCompile
devCompile
}
dependencies {
compile 'com.android.support:appcompat-v7:25.3.1'
releaseCompile (project(path: ':library', configuration: 'release')) {
transitive = true
}
stagingCompile (project(path: ':library', configuration: 'staging')) {
transitive = true
}
devCompile (project(path: ':library', configuration: 'dev')) {
transitive = true
}
}
Did anyone face the same issue ?

Have a look at the migration tips:
Use Flavor Dimensions for variant-aware dependency management
As it states:
Plugin 3.0.0 includes a new dependency mechanism that automatically
matches variants when consuming a library. This means an app's debug
variant automatically consumes a library's debug variant, and so on.
It also works when using flavors—an app's redDebug variant will
consume a library's redDebug variant. To make this work, the plugin
now requires that all flavors belong to a named flavor dimension —even
if you intend to use only a single dimension. Otherwise, you will get
the following build error:
Error:All flavors must now belong to a named flavor dimension.
The flavor 'flavor_name' is not assigned to a flavor dimension.
To resolve this error, assign each flavor to a named dimension, as
shown in the sample below. Because dependency matching is now taken
care of by the plugin, you should name your flavor dimensions
carefully. For example, if all your app and library modules use the
foo dimension, you'll have less control over which flavors are matched
by the plugin.
// Specifies a flavor dimension. flavorDimensions "color"
productFlavors {
red {
// Assigns this product flavor to the 'color' flavor dimension.
// This step is optional if you are using only one dimension.
dimension "color"
...
}
blue {
dimension "color"
...
}

flavorDimensions "mode"
productFlavors {
dev {
// Assigns this product flavor to the "mode" flavor dimension.
dimension "mode"
versionName "1.2"
versionCode 02
}
uat {
// Assigns this product flavor to the "mode" flavor dimension.
dimension "mode"
versionName "1.2"
versionCode 2
}
live {
// Assigns this product flavor to the "mode" flavor dimension.
dimension "mode"
versionName "1.0.1"
versionCode 01
}
}
This is working for me !!
In your case you should just make a flavorDimensions variable and assign the value inside the dev block
flavorDimensions "anyvalue"
dev.initWith(buildTypes.debug)
dev {
dimension "anyvalue"
applicationIdSuffix ".dev"
}
This should help .

Related

firebaseAppDistribution - No signature of method: build.android() is applicable for argument types: (build_run_closure1) values: [build_run_closure1#x

I have a capacitor app and I'm trying to implement the Firebase Distribution with Gradle (https://firebase.google.com/docs/app-distribution/android/distribute-gradle?authuser=1&apptype=aab) but I'm stuck at this error:
No signature of method: build_clqfykx9rkn9m9ygw4eh6w1bu.android() is applicable for argument types: (build_clqfykx9rkn9m9ygw4eh6w1bu$_run_closure1) values: [build_clqfykx9rkn9m9ygw4eh6w1bu$_run_closure1#60526ded]
I've did all the steps of the process and my build.gradle files look like this:
build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath 'com.google.gms:google-services:4.3.5'
// Add the App Distribution Gradle plugin
classpath 'com.google.firebase:firebase-appdistribution-gradle:2.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply from: "variables.gradle"
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
app/build.gradle:
apply plugin: 'com.android.application'
// Apply the App Distribution Gradle plugin
apply plugin: 'com.google.firebase.appdistribution'
android {
compileSdkVersion rootProject.ext.compileSdkVersion
defaultConfig {
applicationId "com.some.app"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName project.hasProperty('version') ? version : '1.0.0'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
// Default: https://android.googlesource.com/platform/frameworks/base/+/282e181b58cf72b6ca770dc7ca5f91f135444502/tools/aapt/AaptAssets.cpp#61
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:.*:!CVS:!thumbs.db:!picasa.ini:!*~'
}
}
flavorDimensions "environment"
productFlavors {
appA {
dimension "environment"
manifestPlaceholders = [displayName:"App A"]
}
appB {
dimension "environment"
applicationIdSuffix ".amigdala"
manifestPlaceholders = [displayName:"App B"]
}
}
signingConfigs {
release {
storeFile file("app-keystore.jks")
storePassword System.getenv("KSTOREPWD")
keyAlias "mykey"
keyPassword System.getenv("KEYPWD")
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
// https://firebase.google.com/docs/app-distribution/android/distribute-gradle?authuser=1&apptype=aab
firebaseAppDistribution {
serviceCredentialsFile "./service-account-key-distribution.json"
artifactType "AAB"
archivePath System.getenv("ARCHIVE_PATH")
releaseNotes "Change this before releasing in production!"
}
}
}
}
repositories {
flatDir{
dirs '../capacitor-cordova-android-plugins/src/main/libs', 'libs'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
implementation project(':capacitor-android')
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation project(':capacitor-cordova-android-plugins')
}
apply from: 'capacitor.build.gradle'
try {
def servicesJSON = file('google-services.json')
if (servicesJSON.text) {
apply plugin: 'com.google.gms.google-services'
}
} catch(Exception e) {
logger.warn("google-services.json not found, google-services plugin not applied. Push Notifications won't work")
}
of course, everything worked until I added this part:
// https://firebase.google.com/docs/app-distribution/android/distribute-gradle?authuser=1&apptype=aab
firebaseAppDistribution {
serviceCredentialsFile "./service-account-key-distribution.json"
artifactType "AAB"
archivePath System.getenv("ARCHIVE_PATH")
releaseNotes "Change this before releasing in production!"
}
I'm very new at modifying build.gradle files so I guess is sometihng syntax related but I can't figure it out. Even if I make small changes like artifactType "AAB" -> artifactType="AAB" I keep bouncing from this error to this one: Task 'appDistributionUploadRelease' not found in root project 'android'.
Any help or leads will be apreciated, thank you.
No signature for method : build.android... Seams to appear when there's something wrong with you Gradle configuration, like missing properties in the firebaseAppDistribution property or wrong file paths. Once I fixed that i had the Task 'appDistributionUploadRelease' not found in root project 'android' problem, which I solved (by pure luck) changing the appDistributionUploadRelease command for appDistributionUploadAppARelease. It seems the task doesn't have a generic command and the flavour must be specified.

React native code push Unable to resolve dependency for ':app#releaseStaging/compileClasspath':

I am trying to setup code push to manage the release of my React Native app.
After setting up new buildTypes as per this guide(https://github.com/Microsoft/react-native-code-push/blob/master/docs/multi-deployment-testing-android.md)
My project does not sync anymore and I get errors on all of my 3rd party libraries I have installed.
Unable to resolve dependency for ':app#releaseStaging/compileClasspath': Could not resolve project :react-native-camera.
...
and the same for some UnitTest that I guess Gradle added automatically
Unable to resolve dependency for
':app#releaseStagingUnitTest/compileClasspath': Could not resolve project :react-native-camera.
I could not find more information in MS Code Push and the example app does not have any 3rd party libraries to look for hints. What is causing this and how to solve this?
my app build.gradle is:
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion
defaultConfig {
applicationId "com.test"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
debug {
// Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key.
buildConfigField "String", "CODEPUSH_KEY", '""'
}
releaseStaging {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
buildConfigField "String", "CODEPUSH_KEY", '"_acY9ZGwTFpxYTaD71ps0O4o352EB1UmlPoK7"' // fake key
}
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
buildConfigField "String", "CODEPUSH_KEY", '"xWEc8lRivDOYHdUAHxBz3hiyiF7hB1WEgPoKQ"' // fake key
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-svg')
implementation project(':react-native-nfc-manager')
implementation project(':react-native-vector-icons')
implementation project(':react-native-camera')
implementation project(':react-native-google-signin')
implementation project(':react-native-fbsdk')
implementation project(':react-native-code-push')
implementation project(':react-native-braintree-xplat')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'com.facebook.android:facebook-android-sdk:4.34.0'
implementation project(':react-native-fbsdk')
implementation(project(":react-native-google-signin")){
exclude group: "com.google.android.gms" // very important
}
implementation 'com.google.android.gms:play-services-auth:16.0.1' // should be at least 15.0.0 to work with the most recent APIs
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services' // <--- this should be the last line
and my android build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 16
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.0.2"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4' // <--- use this version or newer
classpath 'com.google.gms:google-services:3.2.1' // <--- use this version or newer
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
google()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion = '4.4'
distributionUrl = distributionUrl.replace("bin", "all")
}
Fixed it! my 3rd party libraries did not know what to do with the stagingRelease buildtype so I needed to provide a fallback version like so:
buildtypes {
...
releaseStaging {
...
matchingFallbacks = ["release"]
}
Please update your android build.gradle file by using below code:
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
url 'https://maven.google.com'
}
maven {
url "https://jitpack.io"
}
maven {
url "$rootDir/../node_modules/react-native/android"
}
}
}
Hope, it will help.

Data Binding with Android Studio 3.0 Canary 3

I am trying to use DataBinding in my existing project. As per the documentation I added below lines in app module's build.gradle and compiled the project.
dataBinding {
enabled = true
}
I got the below error:
Could not resolve all dependencies for configuration ':app:devDebugCompileClasspath'.
Could not find com.android.databinding:baseLibrary:3.0.0-alpha3.
Searched in the following locations:
file:/C:/Users/incnayak/AppData/Local/Android/sdk/extras/m2repository/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.pom
file:/C:/Users/incnayak/AppData/Local/Android/sdk/extras/m2repository/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.jar
file:/C:/Users/incnayak/AppData/Local/Android/sdk/extras/google/m2repository/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.pom
file:/C:/Users/incnayak/AppData/Local/Android/sdk/extras/google/m2repository/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.jar
file:/C:/Users/incnayak/AppData/Local/Android/sdk/extras/android/m2repository/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.pom
file:/C:/Users/incnayak/AppData/Local/Android/sdk/extras/android/m2repository/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.jar
https://jcenter.bintray.com/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.pom
https://jcenter.bintray.com/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.jar
https://jitpack.io/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.pom
https://jitpack.io/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.jar
https://maven.fabric.io/public/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.pom
https://maven.fabric.io/public/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.jar
Required by:
project :app
Could not find com.android.databinding:baseLibrary:3.0.0-alpha3.
Searched in the following locations:
file:/C:/Users/incnayak/AppData/Local/Android/sdk/extras/m2repository/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.pom
file:/C:/Users/incnayak/AppData/Local/Android/sdk/extras/m2repository/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.jar
file:/C:/Users/incnayak/AppData/Local/Android/sdk/extras/google/m2repository/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.pom
file:/C:/Users/incnayak/AppData/Local/Android/sdk/extras/google/m2repository/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.jar
file:/C:/Users/incnayak/AppData/Local/Android/sdk/extras/android/m2repository/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.pom
file:/C:/Users/incnayak/AppData/Local/Android/sdk/extras/android/m2repository/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.jar
https://jcenter.bintray.com/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.pom
https://jcenter.bintray.com/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.jar
https://jitpack.io/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.pom
https://jitpack.io/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.jar
https://maven.fabric.io/public/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.pom
https://maven.fabric.io/public/com/android/databinding/baseLibrary/3.0.0-alpha3/baseLibrary-3.0.0-alpha3.jar
Required by:
project :app > com.android.databinding:library:1.3.1
project :app > com.android.databinding:adapters:1.3.1
Can anybody help me in solving this? I am using Android Studio 3.0 Canary 3.
My project level gradle
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com'
}
}
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4'
classpath 'com.google.firebase:firebase-plugins:1.1.0'
classpath 'com.android.tools.build:gradle:3.0.0-alpha3'
classpath 'com.google.gms:google-services:3.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
maven { url 'https://jitpack.io' }
}
}
App level gradle
buildscript {
dependencies {
//noinspection GradleDynamicVersion
classpath 'io.fabric.tools:gradle:1.+'
}
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
}
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'io.fabric'
apply from: "../constants.gradle"
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion project.ext.compileSdk
buildToolsVersion "${project.ext.buildtools}"
signingConfigs {
config {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
// Data Binding Library
dataBinding {
enabled = true
}
defaultConfig {
applicationId "com.chanse.cee2048"
minSdkVersion project.ext.minSdk
targetSdkVersion project.ext.targetSdk
versionCode versionCodeNo
versionName versionNameMajor + "." + versionNameMinor + "." + versionNamePatch + "." + versionNameBuild
vectorDrawables.useSupportLibrary = true
versionNameSuffix ' (Beta)'
signingConfig signingConfigs.config
}
buildTypes {
release {
// debuggable true
// shrinkResources true
signingConfig signingConfigs.config
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
signingConfig signingConfigs.config
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
flavorDimensions "chanse"
productFlavors {
dev {
applicationIdSuffix '.debug'
minSdkVersion project.ext.minSdkDebug
// Build only for english and xxhdpi density
resConfigs ("en", "xxhdpi")
// Have a different application name for dev version
resValue "string", "app_name", "Chanse Games Dev"
}
prod {
// The actual minSdkVersion for the application.
minSdkVersion project.ext.minSdk
// Have a different application name for dev version
resValue "string", "app_name", "Chanse Games"
}
}
return void
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:${project.ext.support_library_version}"
compile "com.android.support:cardview-v7:${project.ext.support_library_version}"
compile "com.android.support:recyclerview-v7:${project.ext.support_library_version}"
compile "com.android.support:design:${project.ext.support_library_version}"
compile 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.databinding:library:1.3.1'
implementation 'com.android.databinding:adapters:1.3.1'
compile 'org.jetbrains.kotlin:kotlin-stdlib:1.1.2-4'
apply plugin: 'com.google.gms.google-services'
}
Add these lines to your module-level build.gradle as dependencies; Android Studio 3.0 changed the way it pulls in libraries that you previously downloaded via the SDK manager - https://developer.android.com/studio/build/dependencies.html#google-maven
implementation 'com.android.databinding:library:1.3.1'
implementation 'com.android.databinding:adapters:1.3.1'
You may not need the second line, depending on how you use data binding.
Instead of implementation, you can also use the old compile. Using implementation will avoid build warnings going forward; it's a part of the new Gradle Java library plugin that the Android Gradle plugin uses by default now.
You will also need to add something like the following (typically in your module-level build.gradle) if you don't have it yet - this adds Google's new Maven repository for Android dependencies:
repositories {
maven {
url 'https://maven.google.com'
}
}

Android project there is no output dir after gradle build success?

I am learning Gradle for Android recently. For learning impressively, i create all android application files manually.
my project dirs as below
package name : com.wonbin.gradledemo
project build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
}
}
allprojects {
repositories {
jcenter()
}
}
app module build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.wonbin.gradledemo"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "adroid.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
lintOptions {
htmlReport true
htmlOutput file("lint-results.html")
}
}
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'
testCompile 'junit:junit:4.12'
}
./gradlew build is successful and there are 'intermediates' and 'generated'
dirs , but no outputs dir, i don't know what to do!
Thanks a lot!
You need not only to build, but to assemble it as well.
To do this you can run a gradle task
assembleDebug
Or use Build -> Build APK main menu item

cannot install two flavors of an app with Android Annotations

I have an app using Android Annotations and everything is working fine except one thing - you cannot install both flavors on the same device despite the fact that they have different applicationId.
Researching this I came across some problems (that other people had) with annotation processing and flavors, and as I recall this was an issue also here, but we've manage to add following snippet and everything worked.
apt {
arguments {
androidManifestFile variant.outputs[0]?.processResources?.manifestFile
resourcePackageName android.defaultConfig.applicationId
}
}
Until the other day we've didn't notice, that we couldn't install two flavors at once on one device. I've tried changing the gradle but every time I've ended up with the same problem or breaking the gradle script.
As I've mentioned, I've tried all things that I could think of and the online search didn't turn up anything useful, so if anybody have any idea I'll appreciate it.
Following there are my build.gradle scripts.
Top level:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.google.gms:google-services:2.0.0'
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
mavenLocal()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
App module level:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'android-apt'
android {
signingConfigs {
config {
keyAlias 'release'
keyPassword 'keyPassword'
storeFile file('../storeFile.jks')
storePassword 'storePassword'
}
}
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "some.awsome.app"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
signingConfig signingConfigs.config
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testOptions {
unitTests.returnDefaultValues = true
}
productFlavors {
COGNICARE_personal {
applicationId "some.awsome.app.free"
}
COGNICARE_full {
}
}
packagingOptions {
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
}
}
repositories {
flatDir {
dirs 'libs'
}
maven { url "https://jitpack.io" }
mavenCentral()
}
def android_annotations_version = '3.3.2'
def google_libs_version = '23.3.0'
//some lib versions omitted
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
//some aar lib omitted
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:$google_libs_version"
apt "org.androidannotations:androidannotations:$android_annotations_version"
compile "org.androidannotations:androidannotations-api:$android_annotations_version"
//some libs omitted
compile 'com.android.support:multidex:1.0.0'
//some libs omitted
}
apt {
arguments {
androidManifestFile variant.outputs[0]?.processResources?.manifestFile
resourcePackageName android.defaultConfig.applicationId
}
}
Thanks in advance for any suggestion. Kudos!
OK, so thanks to #ligi pointing me to the right track.
We have a similar project with a very similar setup and the main difference are the Android Annotation used in one of them, an that has mislead me.
The bottom line is that I've had a provider in the manifest that I wasn't aware of, and the authority conflict did occur at that point.
Thanks for your time. Kudos.

Categories

Resources