Manifest merger showing implied permissions why? - android

I recently upgraded to android studio 3.1 and when i build out my project as a signed release the google play console tells me that there are 3 new permissions which i did not add to my manifest.
I then checked the manifest merger report and saw the following explaination:
uses-permission#android.permission.WRITE_EXTERNAL_STORAGE
IMPLIED from /Users/me/Development/QA/android/myapp/app/src/main/AndroidManifest.xml:2:1-222:12 reason: com.google.android.gms.license has a targetSdkVersion < 4
uses-permission#android.permission.READ_PHONE_STATE
IMPLIED from /Users/me/Development/QA/android/myapp/app/src/main/AndroidManifest.xml:2:1-222:12 reason: com.google.android.gms.license has a targetSdkVersion < 4
uses-permission#android.permission.READ_EXTERNAL_STORAGE
IMPLIED from /Users/me/Development/QA/android/myapp/app/src/main/AndroidManifest.xml:2:1-222:12 reason: com.google.android.gms.license requested WRITE_EXTERNAL_STORAGE
What does this mean , why is it saying the license class has a targetSdkVersion less then 4 ?
here are my gradle dependency versions:
firebase_version = '12.0.1'
supportlib_version = '27.0.2'
room_version = '1.0.0'
espresso_version = '3.0.1'
archLifecycleVersion = '1.1.1'
and here are my minimum sdks:
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
applicationId "com.mobile.myapp"
multiDexEnabled true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
i did check the release notes for google api and saw that firebase was updated to 12.0.1 but im already using that. My goal is i do not want these permissions if they are not needed by google. i dont want to include these permission if its just for a license file ? any ideas ? i also do not know what an implied permission is. but let me show you my actual permissions in my manifest:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.mobile.myapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<!-- firebase analytics needs to hold a wake lock -->
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!-- hotline io uses record audio dangerous permission, we will remove it here -->
<uses-permission
android:name="android.permission.RECORD_AUDIO"
tools:node="remove" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true" />
//...
UPDATE:
here is my google play services version:
<integer name="google_play_services_version">12211000</integer>
and i have two google play services components i use here they are:
// Analytics
implementation "com.google.android.gms:play-services-analytics:$firebase_version"
implementation("com.google.android.gms:play-services-auth:$firebase_version") {
force = true
}
WHERE firebase_version = '12.0.1' IS THE LATEST.
and here are the top level dependencies:
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.google.gms:google-services:3.2.0'
classpath 'io.fabric.tools:gradle:1.25.1'
classpath "com.newrelic.agent.android:agent-gradle-plugin:5.+"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}

The following steps rectified the issue:
update gradle wrapper to latest 4.6
then create the following dependency resolution strategy that forces all libraries to comply with latest version (at this time) of google play libraries:
subprojects {
//todo change this to loop once
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex')) {
details.useVersion "$supportlib_version"
}
else if(details.requested.group == 'com.google.android.gms'){
details.useVersion(firebase_version) //this is critical to resolve the error
}
}
resolutionStrategy {
forcedModules = [
"org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version",
"org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
]
}
}
}

Upgrade your Google Play Services to 12.0.1
In its release notes (https://developers.google.com/android/guides/releases) you can find the following:
Adds missing minSdkVersion in -license artifacts to prevent automatic
inclusion of READ_PHONE_STATE and READ_EXTERNAL_STORAGE permissions.

Related

apply plugin: 'com.google.ar.sceneform.plugin' . unable to build [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I'm trying to implement my first sceneform application.
I'm following the following tutorials:
My references:
https://www.youtube.com/playlist?list=PLsOU6EOcj51cEDYpCLK_bzo4qtjOwDWfW
https://developers.google.com/ar/develop/java/quickstart
I'm using the following configurations:
mac os High Sierra - Version 10.13.6 (17G7024)
Android Studio - 3.1.3
My app's gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "myfirstapp.example.com.helloar"
minSdkVersion 26
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// Provides ArFragment, and other UX resources.
implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.11.0'
implementation 'com.google.ar:core:1.11.0'
// Alternatively, use ArSceneView without the UX dependency.
implementation 'com.google.ar.sceneform:core:1.11.0'
}
apply plugin: 'com.google.ar.sceneform.plugin'
sceneform.asset('sampledata/ArcticFox_Posed.obj',
'default',
'sampledata/ArcticFox_Posed.sfa',
'src/main/assets/ArcticFox_Posed')
My project's gradle file:
// 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:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.ar.sceneform:plugin:1.11.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My manifest file :
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="myfirstapp.example.com.helloar">
<uses-permission android:name="android.permission.CAMERA" />
<!-- "AR Required" apps must declare minSdkVersion ≥ 24 -->
<uses-sdk android:minSdkVersion="24" />
<!-- Indicates that the app requires ARCore ("AR Required"). Ensures the app is
visible only in the Google Play Store on devices that support ARCore.
-->
<uses-feature android:name="android.hardware.camera.ar" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data android:name="com.google.ar.core" android:value="required" />
</application>
</manifest>
When I right clicked on .obj file and clicked on import sceneform asset. It's throwing the adding the following to my app's gradle file
apply plugin: 'com.google.ar.sceneform.plugin'
sceneform.asset('sampledata/ArcticFox_Posed.obj',
'default',
'sampledata/ArcticFox_Posed.sfa',
'src/main/assets/ArcticFox_Posed')
Error Given:
Unable to find method 'com.android.build.gradle.api.ApplicationVariant.getMergeResourcesProvider()Lorg/gradle/api/tasks/TaskProvider;'.
Possible causes for this unexpected error include:Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
Kindly help with the fix.
I've upgraded my android studio to 3.4.2 and it's working now.

Wearable not installing app (Android Wear functionality criteria)

I've a Moto 360 and I can't install the wearable app (which is distributed as a beta testing app alongside with a mobile app in the Play Store) in it.
While developing both apps I had no trouble installing it, debugging over bluetooth etc... But when I install the mobile app in my phone through the Play Store the watch doesn't install the wearable app.
Wearable gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
dataBinding{
enabled = true
}
defaultConfig {
applicationId "my.app"
minSdkVersion 21
targetSdkVersion 24
versionCode 56
versionName "1.0.0"
}
...
productFlavors {
dev {
applicationId "my.app.dev"
}
}
dependencies {
compile project(':shared')
compile 'com.google.android.support:wearable:2.0.0-alpha2'
compile 'com.google.android.gms:play-services-wearable:9.6.1'
}
}
Wearable manifest:
...
<uses-feature android:name="android.hardware.type.watch"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
...
Mobile gradle:
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "my.app"
minSdkVersion 15
targetSdkVersion 24
versionCode 56
versionName "1.0.0"
}
...
productFlavors {
dev {
applicationId "my.app.dev"
}
}
}
...
dependencies {
compile project(':shared')
...
wearApp project(':wear')
compile 'com.google.android.gms:play-services-wearable:9.6.1'
}
Mobile manifest:
...
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<!--GCM-->
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE"/>
<uses-permission android:name="${applicationId}.permission.C2D_MESSAGE"/>
...
What could it be?
EDIT: Today I've found through the Google Play Console that my wearable app was rejected, but the error message isn't quite specific. I'm following this functionality criteria and this is the email I've received:
Eligibility issues:
-Your app does not have Android Wear functionality that’s visible to the user.
If you’re adding wearable features to notifications, make sure they're
triggering when appropriate.
You can review this checklist to make sure your wearable app is
packaged correctly:
Include all the permissions declared in the manifest file of the wearable app in the manifest file of the mobile app. For example, if
you specify the VIBRATE permission for the wearable app, you must also
add that permission to the mobile app.
Ensure that both the wearable and mobile APKs have the same package name and version number.
Sign your app.
Test your app on a variety of different Android Wear devices and configurations.
So, what's: WR-VF - App has Wear functionality that is visible to the user.?
Thanks.
Your Gradle files don't show any signing details. You must sign both the mobile and wearable apps with the same certificate.
I ended up finding the solution but forgot to share:
dependencies {
wearApp project(path: ':wear', configuration: 'productionRelease')
...
}
Where 'productionRelease' = productFlavor+buildType
EDIT: gradle-plugin-3-0-0-migration

Adding Google Maps Activity gradle build permanent failure

I have simply went through and attempted to add a a Google Map Activity in Android Studio, ie. Right click -> New -> Google -> Google Maps Activity,
Upon completion, the app attempted to build, and subsequently crashed during the build displaying the error:
Gradle 'appname' project refresh failed
Error: exception during working with external systems
Now, the src folder and manifest file have disappeared and any method including the most basic, super.onCreate display "Cannot resolve method"...
When attempting to clean the project it notes:
Error:The markup in the document preceding the root element must be well-formed.
Error:Cannot read packageName from C:\.....\appanme\app\src\main\AndroidManifest.xml
The build.gradle (Project: appname) file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
build.gradle (Module: app) file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.example.appname"
minSdkVersion 14
targetSdkVersion 22
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
// Additional
compile 'com.google.android.gms:play-services:7.5.0'
compile 'com.squareup.picasso:picasso:2.5.1'
compile 'com.android.support:cardview-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
compile 'com.android.support:palette-v7:22.2.0'
compile 'com.mcxiaoke.volley:library:1.0.+'
compile 'com.android.support:appcompat-v7:22.2.0'
}
Why would this happen? How can it be resolved?
UPDATE
AndroidManifest.xml: This code was merged with the manifest, breaking the app
<<<<<<< Original
...
...
</manifest>
=======
<manifest xmlns:android="http://schemas.android.com/apk/res/android" >
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application>
<meta-data android:name="com.google.android.gms.version" android:value="#integer/google_play_services_version" />
<meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="#string/google_maps_key"/>
<activity android:name="com.example.socialActions.RestaurantLocationActivity"
android:label="#string/title_activity_restaurant_location">
</activity>
</application>
</manifest>
>>>>>>> Added
The manifest has merge conflicts, review it and remove the <<<< parts and any duplicate / outdated info. Alternately if you're in Android studio you should be able to view file history and revert to an earlier version if you are confused.

Android Studio Manifest merger failed minSdkVersion Error

I am trying to add a dependency in my app which has the minimum sdk version newer than my apps so I am getting the following error
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 9 cannot be smaller than version 14 declared in library
Suggestion: use tools:overrideLibrary="com.nononsenseapps.filepicker" to force usage
but I don't know where to add that suggestion so I can build it.
This is how my build.gradle(Module: app) looks right now
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.codedspycamera.android"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
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'
compile 'com.nononsenseapps:filepicker:+'
compile 'com.squareup.picasso:picasso:2.4.0'
}
com.nononsenseapps.filepicker works only on >=14 version android device. I think it will crash if you force it to work on <14 devices. But anyway if you want to do this, you should force using minSdkVersion params from your main app to override library value. Add suggested line to main app manifest. Read this for more information.
Just to make the answer more clear for everyone this is what you have to do
tools:overrideLibrary marker
A special marker that can only be used with uses-sdk declaration to override importing a library which minimum SDK version is more recent than that application's minimum SDK version.
Without such a marker, the manifest merger will fail. The marker will allow users to select which libraries can be imported ignoring the minimum SDK version.
Example, In the main android manifest :
<uses-sdk android:targetSdkVersion="14" android:minSdkVersion="2"
tools:overrideLibrary="com.example.lib1, com.example.lib2"/>
will allow the library with the following manifest to be imported without error :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lib1">
<uses-sdk android:minSdkVersion="4" />
</manifest>
Note that the if multiple libraries are added than they must be separated with a comma ","
For ionic developers
config.xml - add -
<preference name="android-minSdkVersion" value="19" />
bundle.gradle - add
configurations.all {
resolutionStrategy {
force 'com.android.support:support-v4:27.1.0'
}
}

Android Wear app not installing through handset

I'm trying to get a wearable app installed through an Android handset using the 'Package with Android Studio method' found here but it's not working. The apk is never installed to the wearable device. This is the logcat output:
07-28 15:11:54.107 766-820/? W/PackageManager﹕ Unknown permission com.google.android.wearable.READ_SETTINGS in package com.google.android.gms
07-28 15:11:54.117 766-820/? W/PackageManager﹕ Not granting permission com.google.android.gm.permission.AUTO_SEND to package com.google.android.wearable.app (protectionLevel=2 flags=0x88be44)
07-28 15:11:54.117 766-820/? W/PackageManager﹕ Not granting permission android.permission.MEDIA_CONTENT_CONTROL to package com.google.android.wearable.app (protectionLevel=18 flags=0x88be44)
07-28 15:11:55.047 632-632/? D/WearablePkgInstaller﹕ Got PackageUpdateReceiver message Intent { act=android.intent.action.PACKAGE_REMOVED dat=package:my.package.name flg=0x4000010 cmp=com.google.android.wearable.app/com.google.android.clockwork.companion.packagemanager.PackageUpdateReceiver (has extras) }
07-28 15:11:55.177 632-632/? D/WearablePkgInstaller﹕ Got PackageUpdateReceiver message Intent { act=android.intent.action.PACKAGE_ADDED dat=package:my.package.name flg=0x4000010 cmp=com.google.android.wearable.app/com.google.android.clockwork.companion.packagemanager.PackageUpdateReceiver (has extras) }
As a side note I am able to package manually (also described in the link above) and the apk gets installed on the wearable device when I run it on the handset. I am using buildToolsVersion 20.0.0, I'm running Android Studio 0.8.2 and have this line in my handset module's build.gradle:
wearApp project(':wearable')
I've run out of ideas on how to debug this, the logs seem pretty useless. Any ideas?
EDIT: Going to post relevant sections of Manifest and build.gradle for both the handset and wearable module.
Handset Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.package.name"
android:installLocation="auto"
android:versionCode="259"
android:versionName="4.6.1">
<!-- =========== -->
<!-- PERMISSIONS -->
<!-- =========== -->
<permission
android:name="my.app.name.permission.C2D_MESSAGE"
android:protectionLevel="signature"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<!-- ====================== -->
<!-- APPLICATION PROPERTIES -->
<!-- ====================== -->
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="19" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:xlargeScreens="true"/>
<application
android:name=".AppState"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/Theme.MyApp"
android:hardwareAccelerated="true">
<!-- ==================== -->
<!-- GOOGLE PLAY SERVICES -->
<!-- ==================== -->
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version"/>
<!-- ================== -->
<!-- Android Wear -->
<!-- ================== -->
<service
android:name=".wear.DataLayerListenerService" >
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>
<!-- This is used for manual packaging I have this commented out when -->
<!-- packaging with Android Studio-->
<!--<meta-data android:name="com.google.android.wearable.beta.app"-->
<!--android:resource="#xml/wearable_app_desc"/>-->
...The rest of the activities
</application>
</manifest>
Handset build.gradle
buildscript {
repositories {
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
}
}
apply plugin: 'com.android.application'
apply plugin: 'crashlytics'
apply plugin: 'newrelic'
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.android.support:support-v4:20.0.+'
compile 'com.android.support:appcompat-v7:20.0.+'
compile project(':facebook')
compile project(':mopub-sdk')
compile project(':GooglePlay')
compile 'com.newrelic.agent.android:android-agent:3.+'
compile 'com.crashlytics.android:crashlytics:1.+'
androidTestCompile fileTree(dir: 'tests/libs', include: '*.jar')
wearApp project(':wearable')
}
android {
compileSdkVersion 19
buildToolsVersion '20.0.0'
//Build type is debug to avoid conflict with Proguard
testBuildType = "debug"
defaultConfig {
testApplicationId "my.package.name.test"
testInstrumentationRunner "com.zutubi.android.junitreport.JUnitReportTestRunner"
}
lintOptions {
// We do not want to abort the build due to lint errors
abortOnError false
}
sourceSets {
// Main is the default unless stated otherwise
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Testing
androidTest.setRoot('tests')
androidTest {
java.srcDirs = ['tests/src']
res.srcDirs = ['tests/res']
}
// Cannot add beta icons in here because custom flavour source sets are created
// during compilation and name duplication will result in a crash
}
signingConfigs {
debug {
storeFile file("**")
storePassword "***"
keyAlias "***"
keyPassword "***"
}
release {
storeFile file("***")
storePassword "***"
keyAlias "***"
keyPassword "***"
}
}
buildTypes {
// Development configuration
debug {
debuggable true
jniDebugBuild true
signingConfig signingConfigs.debug
runProguard false
}
// Release configuration
release {
debuggable false
jniDebugBuild false
signingConfig signingConfigs.release
// COMMENTED PROGUARD OUT FOR NOW TO SEE IF IT WILL HELP
// // Configure ProGuard
// runProguard true
// // General configuration
// proguardFile 'proguard/proguard.cfg'
// // Add all of our component-specific configurations (excluding the Android generic, as we want it to be last)
// FileTree tree = fileTree(dir: 'proguard', include: '*.txt', exclude: 'Android.txt')
// tree.each {File file ->
// proguardFile file.getCanonicalPath()
// }
// // Add a fallback configuration for all Android apps
// proguardFile 'proguard/Android.txt'
}
// Release configuration, but debuggable and without ProGuard
// Used for testing features like G+ and in-app billing where a release config is required
staging {
debuggable true
jniDebugBuild true
signingConfig signingConfigs.release
runProguard false
}
}
productFlavors {
production {
applicationId "my.package.name"
}
internalBeta {
applicationId "my.internalbetapackage.name"
// Beta icons
sourceSets.internalBeta.res.srcDirs = ['res-beta/internal']
}
externalBeta {
applicationId "my.externalbetapackage.name"
// Beta icons
sourceSets.externalBeta.res.srcDirs = ['res-beta/external']
}
testing{
applicationId "my.package.name"
}
}
// Without this, gradle will complain that duplicate files were added to the APK, see:
// http://stackoverflow.com/questions/20673888/duplicate-files-copied-android-studio-0-4-0
packagingOptions {
exclude 'META-INF/LICENSE.txt' // twitter4j
exclude 'META-INF/ASL2.0' // jackson
exclude 'META-INF/LICENSE' // jackson
exclude 'META-INF/NOTICE' // jackson
}
}
task makeTestApks {
dependsOn "assembleProductionRelease"
dependsOn "assembleProductionTest"
}
Wearable Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.package.name">
<uses-feature android:name="android.hardware.type.watch" android:required="false"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#android:style/Theme.DeviceDefault" >
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name=".WearReaderActivity"
android:label="MyApp" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="my.package.name.READ"/>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service
android:name=".wear.DataLayerListenerService" >
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>
</application>
</manifest>
Wearable build.gradle
repositories {
mavenCentral()
}
apply plugin: 'com.android.application'
apply plugin: 'newrelic'
android {
compileSdkVersion 19
buildToolsVersion '20.0.0'
defaultConfig {
minSdkVersion 19
targetSdkVersion 19
versionCode 259
versionName "4.6.1"
}
signingConfigs {
debug {
keyAlias '***'
keyPassword '***'
storeFile file('sameAsHandset/debug.keystore')
storePassword '***'
}
release {
storeFile file("sameAsHandset/android.keystore")
storePassword "***"
keyAlias "***"
keyPassword "***"
}
}
buildTypes {
release {
debuggable true
jniDebugBuild false
signingConfig signingConfigs.release
}
}
productFlavors {
production {
applicationId "my.package.name"
}
internalBeta {
applicationId "my.internalBetaPackage.name"
// Beta icons
sourceSets.internalBeta.res.srcDirs = ['res-beta/internal']
}
externalBeta {
applicationId "my.externalBetaPackage.name"
// Beta icons
sourceSets.externalBeta.res.srcDirs = ['res-beta/external']
}
testing{
applicationId "my.package.name"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':GooglePlay')
compile 'com.newrelic.agent.android:android-agent:3.+'
}
To Answer #odiggity specifically, in build.gradle file of your phone app, you should mention the exact name of the wear app folder. If you created the project in Android Studio, then your build.gradle should look like this:
wearApp project(':wear')
This can happen because of the following reasons:
Wear & Mobile app's "permissions" are not same (Wear App permissions should be a subset of Mobile App permissions).
This is not documented anywhere on developers website, however I found this with my personal experience. The reason I can think of behind this restriction is, Google want to prevent sneaky developers to exploit users & their privacy.
Package name of Wear & Mobile apps are not matching.
VersionNumber & VersionName of both Wear & Mobile app not matching
Application ID (build.gradle file) of Mobile & wear app are not matching.
by default wearable packages are only included in release builds
both apps must be signed with the same key
as of Android Studio 3.0 apk builds created with run are test only builds that don't allow installation on wear (returnCode -15, see this information)
Asset Compression
If you are using Eclipse for development, make sure you turn off the "Asset Compression" otherwise the ".apk" file in raw folder will get double compressed & the phone won't be able to recognize if the Mobile app is packaging wear app or not.
Best Solution:
Use Android Studio.
Create Android Project
Select Phone & Wear project
Follow the steps for project creation
Copy all the permissions used in Wear app to Mobile app's Manifest or vice versa
Debugging
When you don't find the wear app on the wearable you can always look into logs of both devices to see what is going on. You can filter on WearablePkgInstaller to find all logging related to wearable package installation.
From the Wear OS app on you device trigger the "resync apps" option from "advanced settings" and check the logs. Alternative way to sync only the wearable for your app is to reinstall your app. At that point the wearable is also synced for your package.
Device logging should list something like:
11-07 14:58:53.127 3330-8739/? I/WearablePkgInstaller: Setting DataItem to install wearable apps for com.spotify.music
With com.spotify.music being your app Id. This is just an example for Spotify.
And on the watch (debug over bluetooth or USB) you can find logging with this same filter showing issues or success:
11-07 15:00:02.533 1032-1048/? I/WearablePkgInstaller: Package com.spotify.music was installed.
Most error messages are self explanatory. You can find many examples of these errors in the source code of WearPackageInstallerService class. Some however are just a returnCode. For these return codes check the values in this PackageManager source code.
I had ussue with wear product flavors. I had flavors in both handheld and wear apps. To solve my issue I used next code in build.gradle handheld app file:
freeWearApp project(path: ':wear', configuration: 'wearfreeRelease')
fullWearApp project(path: ':wear', configuration: 'wearfullRelease')
where, free and full are flavors from handheld module, wearfree and wearfull are flavors from wear mudule, Release is name of wear module buildtype.
And don't forget publishNonDefault true in the android block of the wear gradle.
I had this problem even after checking the package names, application IDs, and making sure the wear module didn't have any permissions that the handheld module didn't.
My problem was that I was requesting the permission android.permission.BIND_NOTIFICATION_LISTENER_SERVICE in AndroidManifest.xml for the wearable module. It seems that this should only be requested for the handheld module.
as far as I know product flavors are not supported at the moment, either use the manual build (asset or raw) or remove the product flavors.
From my experience it only works when building a signed release build. When deploying a debug build it never installed the wear app for me. With signed release it worked with buildToolsVersion "19.1.0".
In this specific case I can see that you are using "compile project(':GooglePlay')". Is that the latest version? (compile 'com.google.android.gms:play-services-wearable:+')
Just wanted to add something that I haven't seen in many answers.
You have to match the applicationId in your handheld app and wear app.
I previously thought that you needed to have <uses-feature android:name="android.hardware.type.watch" /> in both the handheld and watch manifest, with add: android:required="true" for the wearable manifest and android:required="false" for the device.
THIS IS FALSE. You do not need the above in the handheld manifest. In fact with Wear 2.0 coming up Google has made some changes that will not allow you to upload any apk with minSdk lower than 23 if <uses-feature android:name="android.hardware.type.watch" /> is in your handheld app. Sorry for any confusion.
I've been having this issue recently, and in the end the following fixed it;
Uninstall previous app
Restart Phone
Restart wear
Disconnect and reconnect wear
Re-Sync apps in Android Wear application
And then it popped up on the watch. Before this I tried everything and was convinced the build was not working right
Got the same problem, it turned out that newrelic is instrumenting the Android Wear App. Try to comment the line:
// apply plugin: 'newrelic'
I couldn't find a way to tell newrelic to keep away from the the wear app...

Categories

Resources