My project was working fine when I had just a simple handheld app with one wear app.
Now, I've introduced three flavors to the handheld app and kept the same single flavor wear app.
The problem is that release builds are not being pushed to the wearable.
My project looks like this:
smartphone's build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 8
versionName "3.1.0"
applicationId "br.com.test"
}
signingConfigs {
...
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig = android.signingConfigs.release
}
debug {
applicationIdSuffix ".debug"
versionNameSuffix "-debug"
zipAlignEnabled true
}
}
productFlavors {
generic {
applicationId "br.com.generic"
}
abc {
applicationId "br.com.teste.abc"
}
company {
applicationId "br.com.test.company"
}
}
}
dependencies {
genericWearApp project(path:':wear', configuration: 'genericRelease')
abcWearApp project(path:':wear', configuration: 'abcRelease')
companyWearApp project(path:':wear', configuration: 'companyRelease')
compile project(':common')
}
and wear's build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
publishNonDefault true
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 8
versionName "3.1.0"
applicationId "br.com.test"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".debug"
versionNameSuffix "-debug"
zipAlignEnabled true
}
}
productFlavors {
generic {
applicationId "br.com.generic"
}
abc {
applicationId "br.com.teste.abc"
}
company {
applicationId "br.com.test.company"
}
}
}
dependencies {
compile project(':common')
}
Why does the wearable does not gets the app? Any tips?
I was only a matter of tricky details... This repo offers a really nice example and was enough to help me solve this:
https://github.com/vngrs/PomoPomoAndroid/
Related
I have modules, app and favorite, and favorite module was dynamic features. I use navigation component, and My dynamic features graph that have detail page, and for detail page i use a fragment (RecipeInformation) in app module. like this:
it works fine, but there's an issue when i'm trying change minifyEnabled to true, (obfuscate)
then, this error happen :
> Task :favorite:dexBuilderDebug
> Task :favorite:mergeProjectDexDebug
> Task :app:minifyDebugWithR8 FAILED
AGPBI: {"kind":"error","text":"Type com.example.recipes.ui.detail.RecipeInformationFragmentArgs$Companion is defined multiple times: C:\\Users\\wahyu\\rootProject\\Project\\Android\\Recipes\\app\\build\\intermediates\\module_and_runtime_deps_classes\\debug\\base.jar:com/example/recipes/ui/detail/RecipeInformationFragmentArgs$Companion.class, C:\\Users\\wahyu\\rootProject\\Project\\Android\\Recipes\\favorite\\build\\intermediates\\module_and_runtime_deps_classes\\debug\\feature-favorite.jar:com/example/recipes/ui/detail/RecipeInformationFragmentArgs$Companion.class","sources":[{"file":"C:\\Users\\wahyu\\rootProject\\Project\\Android\\Recipes\\app\\build\\intermediates\\module_and_runtime_deps_classes\\debug\\base.jar"}],"tool":"R8"}
i've try invalidating, rebuild, clean but it wont work.
and i've try to refactor primitive id args with Parcelable and annotate it with #Keep (like documentation says) but it still has a same error.
Here's my app build.gradle :
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'androidx.navigation.safeargs.kotlin'
id 'com.google.dagger.hilt.android'
}
apply from: "../shared_dependencies.gradle"
android {
namespace 'com.example.recipes'
compileSdk 33
defaultConfig {
applicationId "com.example.recipes"
minSdk 21
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
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
}
dynamicFeatures = [':favorite']
}
dependencies {
api project(":core")
//? safeArgs
api "androidx.navigation:navigation-fragment-ktx:2.5.3"
api "androidx.navigation:navigation-ui-ktx:2.5.3"
api "androidx.navigation:navigation-dynamic-features-fragment:2.5.3"
//? ui
implementation "androidx.drawerlayout:drawerlayout:1.1.1"
}
kapt {
correctErrorTypes true
}
favorite build.gradle
id 'com.android.dynamic-feature'
id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
id 'com.google.dagger.hilt.android'
id 'androidx.navigation.safeargs.kotlin'
}
apply from: "../shared_dependencies.gradle"
android {
namespace 'com.example.recipe.favorite'
compileSdk 33
buildFeatures{
viewBinding true
}
defaultConfig {
minSdk 21
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation project(":app")
implementation project(":core")
}
what seem's to be the problem? i need help
I am trying to simply build a second module in my Android project. I have refered to another module, because there are some Activities and classes I want to reuse. This is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "nl.minerall.sapphire.browser"
minSdkVersion 19
targetSdkVersion 19
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions {
}
lintOptions {
disable "MissingTranslation"
checkReleaseBuilds false
}
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile project(path: ':sapphirelib')
compile project(path: ':app')
}
The build.gradle of sapphirelib is:
apply plugin: 'com.android.library'
android {
compileSdkVersion 24
buildToolsVersion '25.0.0'
defaultConfig {
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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'
})
testCompile 'junit:junit:4.12'
compile files('libs/simple-xml-2.7.1.jar')
compile project(path: ':Zebra_SDK_DS3678')
}
And of app:
apply plugin: 'com.android.application'
android {
signingConfigs {
demo {
keyAlias 'FlexDemo'
keyPassword '******'
storeFile file('/path/to/file.jks')
storePassword '******'
v2SigningEnabled false
}
full {
keyAlias 'PocketFull'
keyPassword '****'
storeFile file('/path/to/file.jks')
storePassword '*****'
v2SigningEnabled false
}
}
compileSdkVersion 19
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "nl.minerall.sapphire.pocket"
minSdkVersion 19
targetSdkVersion 19
}
productFlavors {
full {
applicationId "nl.minerall.sapphire.pocket.full"
signingConfig signingConfigs.full
resValue "string", "app_name", "Sapphire Pocket"
versionCode 13
versionName "Flex 2.0.25"
}
demo {
applicationId "nl.minerall.sapphire.pocket.demo"
signingConfig signingConfigs.demo
resValue "string", "app_name", "Pocket Demo"
versionCode 12
versionName "Flex 1.13 DEMO"
}
ipsdemo {
applicationId "nl.minerall.sapphire.pocket.ipsdemo"
signingConfig signingConfigs.demo
resValue "string", "app_name", "Pocket IPS Demo"
versionCode 12
versionName "Flex 1.13 IPS DEMO"
}
sourceSets.ipsdemo.root = "src/demo"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions {
}
lintOptions {
disable "MissingTranslation"
checkReleaseBuilds false
}
}
dependencies {
compile 'com.android.support:support-v4:19.1.0'
compile project(path: ':sapphirelib')
}
When I build, I get the error
Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Material.Light.NoActionBar'.
and I am thrown into a values-v21.xml file that is apparently auto-generated. The styles.xml I am using is:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
</resources>
It completely beats me where the android:Theme.Material.Light.NoActionBar comes from ...
Imagine this setup:
android {
buildTypes {
debug {
applicationIdSuffix ".debug"
}
}
productFlavors {
foo {
applicationId defaultConfig.applicationId + '.foo'
}
}
}
How can I set up a dynamic string value such as
resValue "string", "package_name", applicationId
so that it includes the applicationIdSuffix for debug builds?
If I add this to defaultConfig, its my defaultConfig's applicationId that is set. If I add this to the flavor configuration, it is missing the applicationIdSuffix (this is null at this level).
Any hints?
The cool part about applicationIdSuffix is that you can use it in flavors as well as in build types. Check this out:
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "dev.bmax.suffixtext"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix '.debug'
}
}
productFlavors {
prod {
applicationIdSuffix '.prod'
}
mock {
applicationIdSuffix '.mock'
}
}
}
Now, when I build my 'prodDebug' variant the final application ID is 'dev.bmax.suffixtext.prod.debug', which is what you want if I understand your question correctly.
EDIT
You can access the variant's name in a Gradle task like this:
applicationVariants.all { variant ->
// Use 'variant.name'
}
Gradle Android Plugin version 0.14.3 added support of the variant specific BuildConfigField/resValue:
applicationVariants.all { variant ->
variant.resValue "string", "name", "value"
}
Could not find property jni and source set 'main'
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 21
buildToolsVersion = "22.0.1"
defaultConfig.with {
applicationId = "com.example.native_activity"
minSdkVersion.apiLevel = 9
targetSdkVersion.apiLevel = 9
}
sourceSets.main {
jni.srcDirs = [] // This prevents the auto generation of Android.mk
jniLibs.srcDir = 'src/main/libs'
// This is not necessary unless you have precompiled libraries in your project.
}
}
Here is the stacktrace:
Caused by: org.gradle.model.internal.core.ModelRuleExecutionException: Exception thrown while executing model rule: model.android
at org.gradle.model.internal.registry.DefaultModelRegistry.fireMutation(DefaultModelRegistry.java:485)
at org.gradle.model.internal.registry.DefaultModelRegistry.access$1500(DefaultModelRegistry.java:45)
at org.gradle.model.internal.registry.DefaultModelRegistry$RunModelAction.apply(DefaultModelRegistry.java:1464)
at org.gradle.model.internal.registry.DefaultModelRegistry.transitionTo(DefaultModelRegistry.java:341)
at org.gradle.model.internal.registry.DefaultModelRegistry.transition(DefaultModelRegistry.java:419)
at org.gradle.model.internal.registry.DefaultModelRegistry.atStateOrMaybeLater(DefaultModelRegistry.java:183)
at org.gradle.model.internal.registry.DefaultModelRegistry.atStateOrLater(DefaultModelRegistry.java:175)
at org.gradle.execution.TaskNameResolver.selfClose(TaskNameResolver.java:101)
at org.gradle.execution.TaskNameResolver.selfClosedTasksNode(TaskNameResolver.java:114)
... 60 more
Caused by: org.gradle.api.internal.MissingMethodException: Could not find method main() for arguments [build_f1cmjkxjjzysskbrs6852ixyj$_run_closure1_closure2_closure7#8c09fa7] on SourceSet container.
I googled like mad for the last 2 hours...
As Awanish said - read the Experimental Plugin User Guide step by step VERY carefully. For even more clearance check the build.gradle files in the ndk-samples provided by google.
sourceSets.main { } has different syntax and should be outside the android { } block. In your case it should look something like this:
model {
android {
//...
}
android.sources {
main {
jniLibs {
source {
srcDirs 'libs'
}
}
}
}
}
In my case it was an exact opposite to tochkov answer:
This syntax - with the jniLibs outside android block - gave me an error:
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.mycompany.myproject"
minSdkVersion 17
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
and this syntax - inside android block - fixed it:
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.mycompany.myproject"
minSdkVersion 17
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['src/main/jniLibs']
}
}
}
It seems like you are trying to use the grade experimental plugin!
Make sure you have grade-2.5 in your gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
and this in your project's build.gradle dependencies tag
classpath 'com.android.tools.build:gradle-experimental:0.1.0'
Instead of guessing a lot of things, let me redirect you to the user guide, where the documentation explains migration from the standard to experimental plugin in detail. Take a look here!
Try these fixes. Post more details if these don't work for you, I will try to help. :)
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.jeremy.test"
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFiles.add(file('proguard-android.txt'))
}
}
ndk {
moduleName "hello-android-jni"
}
}
android.sources.main {
java.source.srcDirs = ["src/main/java", "/Users/jeremy/Repositories/hello/src/android/java"]
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}
The above is copied from my experimental ndk project, this works for me.
See the android.sources.main section.
I'm having the following warning in my gradle build file
Not all execution paths return a value
This inspection reports on missing groovy return statement at the end of methods returning
and this is the code in that file
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "ac.company.srikar.quickhelpindia"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
android {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
}
}
Can anyone tell what is the issue here and how to get rid of this warning.
With Android Studio 2.2 I had to add a return void before the final bracket in the android section.
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.app"
minSdkVersion 19
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
minifyEnabled false
shrinkResources false
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
standard {
applicationId "com.example.app.standard"
}
free {
applicationId "com.example.app.free"
}
}
// `return void` removes the lint error: `Not all execution paths return a value`.
return void
}
I have been getting this same warning and I think it is incorrect. I have read through the gradle documentation and it does not appear that a return type is needed. However, the warnings bug me and the only way I could get rid of it was to add return true.
buildTypes {
android {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
return true
}
}
}
I doubt this is the "correct" solution; however, it does remove the warnings and it doesn't cause any issues.
I fixed this by adding the recommended suppression string from inspection:
//noinspection GroovyMissingReturnStatement
android {
compileSdkVersion 25
buildToolsVersion "23.0.3"
...
I got rid of this warning when I specified both, minifyEnabled and shrinkResources.
buildTypes {
debug {
minifyEnabled false
shrinkResources false
}
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
It seems that this is an issue fixed in Android Studio 2.3:
https://code.google.com/p/android/issues/detail?id=223575