Issue with bundling Android Wear1 app's with android gradle plugin 3.0.1 - gradle

I cannot get the Wear1 signed APK into the res/raw folder of my signed mobile apk file since using the latest android gradle plugin 3.0.1
I have to use the latest gradle to get the google repo for certain dependencies.
I have checked the wear apk and it is signed with my production signature.
I know the preferred method going forward is to unbundle and I can successfully do that but Google's acknowledged latency issue on installing Wear 1 apps that way makes it unattractive at this time.
Below are my gradle files.
Project build.config
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
Mobile build.config
apply plugin: 'com.android.application'
apply from: rootProject.file('shared-config/android-signing.gradle')
android {
compileSdkVersion 27
buildToolsVersion '27.0.2'
defaultConfig {
applicationId "com.me.myapp"
minSdkVersion 18
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.release
}
}
flavorDimensions "environment"
productFlavors {
development {
dimension "environment"
}
production {
dimension "environment"
}
}
}
configurations {
developmentReleaseWearApp
productionReleaseWearApp
}
dependencies {
implementation 'com.google.android.gms:play-services-wearable:11.8.0'
implementation 'com.android.support:support-compat:27.1.0'
implementation 'com.android.support:percent:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
developmentReleaseWearApp project(path: ':wear', configuration: 'wear1Release')
productionReleaseWearApp project(path: ':wear', configuration: 'wear1Release')
implementation 'com.android.support:support-annotations:27.1.0'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.android.support:preference-v14:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:support-v13:27.1.0'
provided 'com.google.android.wearable:wearable:2.2.0'
implementation 'com.google.android.support:wearable:2.2.0'
}
Wear build.config
apply plugin: 'com.android.application'
apply from: rootProject.file('shared-config/android-signing.gradle')
android {
compileSdkVersion 27
buildToolsVersion '27.0.2'
publishNonDefault true
defaultConfig {
applicationId "com.me.myapp"
minSdkVersion 23
targetSdkVersion 27
versionCode 2
versionName "1.0"
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.release
}
}
flavorDimensions "wearVersion"
productFlavors {
wear1 {
dimension "wearVersion"
// Use the defaultConfig value
}
wear2 {
dimension "wearVersion"
minSdkVersion 24
}
}
configurations {
wear1Release
wear2Release
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.google.android.gms:play-services-wearable:11.8.0"
implementation "com.android.support:support-compat:27.1.0"
implementation "com.android.support:support-annotations:27.1.0"
implementation "com.android.support:appcompat-v7:27.1.0"
implementation "com.android.support:recyclerview-v7:27.1.0"
implementation "com.android.support:percent:27.1.0"
implementation "com.android.support:support-v4:27.1.0"
implementation "com.android.support:wear:27.1.0"
implementation "com.google.android.support:wearable:2.2.0"
implementation "com.android.support.constraint:constraint-layout:1.1.0-beta5"
provided 'com.google.android.wearable:wearable:2.2.0'
}
settings.gradle
include ':mobile'
include ':wear'
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip

I was having the same problem this week. Today I finally managed to get the wear app correctly embedded into the mobile app APK using the 3.0.1 gradle. I added a productFlavor to my wear app build.gradle to match the productFlavor of the mobile app that I was generating the build for. Trying to specify a differently-named wear app configuration in the mobile app's build.gradle dependency list seemed to be the problem for me.
I would suggest trying to add development and production flavors to your wear app build.gradle:
development {
dimension "wearVersion"
// Use the defaultConfig value
}
production {
dimension "wearVersion"
// Use the defaultConfig value
}
and then change your mobile app build.gradle dependency to simply:
wearApp project(path: ':wear')
When you generate the build, it should match productFlavor to productFlavor by default and that is working for me.

Related

How to Sign Android App to avoid App not installed from Play Store error?

I'm trying to release new update to my users on play store, but whenever I roll out the release all users complaint me about app is not updating or not installing after downloading update from play store.
How do I configure my gradle / manifest / or build settings such that users will successfully install the new update without needing to uninstall the existing apk from the device?
Please correct me if my settings are configured incorrectly.
build.gradle(app)
android {
compileSdkVersion 31
defaultConfig {
applicationId "com.myapp"
minSdkVersion 23
targetSdkVersion 31
versionCode 11
versionName "2.2.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.debug
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
debuggable true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.debug
}
debug {
signingConfig signingConfigs.debug
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
bundle{
language{
enableSplit=false
}
}
}
build.gradle(project)
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
proguard-rules.pro
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-keepattributes Signature
-keep class androidx.appcompat.widget.** { *; }
-keepclassmembers class com.myapp.Firebase** {
*;
}
I'm not able to understand which part of the mentioned code having issues with. Sometimes my build takes so much time during running app for testing on device. I new in this signing process. I will really appreciate your help.

how to add repositories and dependencies in Gradle for android . Actually am trying to integrating SDk in my existing app

Can Anyone explain me what is Version Tag for git in this, I am getting error while importing this.
apply plugin: 'com.android.application'
buildscript {
repositories {
maven { url 'https:example.com' }
jcenter()
mavenCentral()
mavenLocal()
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.jatinder.bdugame"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'org.bitbucket.5elements:SmartTones-SDK:VERSION_TAG'
}
Error:
Error:(45, 13) Failed to resolve: org.bitbucket.5elements:SmartTones-SDK:VERSION_TAG
Show in File<br>Show in Project Structure dialog
What does you question have to do with Git or Maven?
It does not even have anything to do with Android, besides coming from an Android project.
You declared the compile time dependency org.bitbucket.5elements:SmartTones-SDK:VERSION_TAG which means group org.bitbucket.5elements, artifact SmartTones-SDK, version VERSION_TAG. This combination is not found in any of your declared repositories, so it fails to be resolved, just as the error tells you.

My Android Studio Project's APK is not zip aligned (Upload Failure)

I keep on failing to upload the signed APK file generated from Android Studio, even though I have tried many different solutions to solve it.
This is what I get when uploading:
I have also seen some solutions to write zipalign commands, but I always get the "command not found" message when entering the command in my mac's terminal.
And this is my configuration in the build.gradle (Module: app) file inside the project:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.name.product"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
zipAlignEnabled true
}
}
repositories {
flatDir {
dirs 'libs'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.squareup.okhttp3:okhttp:3.0.1'
compile(name:'material-search', ext:'aar')
}
I found this solution and it solved my problem:
https://stackoverflow.com/a/37842438/4846301
It was all about changing 1 line in the build.gradle file to this:
'com.android.tools.build:gradle:2.1.2'

Android Gradle Build Resource.getIdentifier() always returns 0

I'm getting started on porting my Game over to the new Gradle Build system for Android.
I'm using the Resource.getIdentifier() method to load some resources by name instead of ID. However, ever since switching to the Gradle build, this call always returns 0. The assets are included in the built jar, and the R.class in the dex file contains all of my resources and ID's as expected, so I am at a loss as to explain this. This code worked before I changed to the gradle build. My build.gradle is below:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
dependencies {
compile 'com.android.support:support-v4:18.0.+'
}
android {
compileSdkVersion 18
buildToolsVersion "19"
defaultConfig {
minSdkVersion 10
targetSdkVersion 18
}
buildTypes {
debug {
packageNameSuffix ".debug"
}
release {
runProguard true
proguardFile getDefaultProguardFile('proguard-android.txt')
}
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
instrumentTest.setRoot('tests')
}
}
TIA.
D'oh! my problem was that Resources.getIdentifer() takes 3 parameters, one of which is the package name. The debug section of my gradle script was tacking on ".debug" to the package name on the device. Solution is to remove the .debug suffix in the build.gradle.

Android Studio gradle compilation error

I wonder if you can help, I'm not a very exerienced developer but trying my had at Android Development. I'm using Android Studio which uses gradle. I'm getting the following compilation error:
Gradle: A problem occurred configuring project ':HelloWorld'.
Failed to notify project evaluation listener.
Configuration with name 'default' not found.
My folder structure is:
HelloWorldProject
.HelloWorld
.libraries
..facebook
..build.gradle
.src
..main
..build.gradle
...java
....com.helloworld
.....firstPage
.gradle
..wrapper
...gradle-wrapper.jar
...gradle-wrapper.properties
.build.gradle
.settings.gradle
.gradle.properties
my ./build.gradle in the root is empty
my ./setting.gradle file contains:
include ':libraries:facebook', ':HelloWorld'
my ./HelloWorld/build.gradle is:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
dependencies {
compile project(':libraries:facebook')
}
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 16
}
}
my ./HelloWorld/src/build.gradle contains:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
dependencies {
dependencies {
compile project(':libraries:facebook')
}
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 16
}
}
The problem here, in most cases, is a library doesn't have a build.gradle file. In this case, it would be the facebook library.

Resources