I'm working on a small Android Wear OS app and am pretty close to a release version.
The app is built in Android Studio using the Wear OS application template and it currently has just the one Activity (MainActivity).
Up to now I have been building a debug variant without any problems. I didn't need to tweak anything to make that work.
But now I am trying to build a release variant I am getting the following error:
Error: MainActivity must extend android.app.Service [Instantiatable]
My AndroidManifest.xml is as follows and it's the <service android:name="MainActivity" that is flagging as the error in the editor with MainActivity underlined in red:
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#android:style/Theme.DeviceDefault">
<uses-library
android:name="com.google.android.wearable"
android:required="true" />
<meta-data
android:name="com.google.android.wearable.standalone"
android:value="true" />
<!-- Recommended for Android 9 (API level 28) and lower. -->
<!-- Required for Android 10 (API level 29) and higher. -->
<service
android:name="MainActivity"
android:foregroundServiceType="location" >
<!-- Any inner elements would go here. -->
</service>
<activity
android:name=".MainActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
My MainActivity currently extends Activity
public class MainActivity extends Activity {
I have no idea how to resolve this... it doesn't make sense to me that the debug variant builds and runs fine but the release variant doesnt.
The only release build specific stuff in my build.gradle is:
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
When I switch back to the debug variant the app build and runs perfectly on both an AVD Wear OS device and on an actual device.
Related
I added flutter as a module to my existing app and the starting activity of the app is a subclass of io.flutter.embedding.android.FlutterFragmentActivity.
This is very weird but in debug mode everything works as expected but in release mode I see a white screen with the following log flooded
[DP] cancelDraw null isViewVisible: true
I tried monitoring flutter logs using flutter logs but they do not show anything, which it should because I have added print statements to my main method.
I tried adding the following to the release config
minifyEnabled false
shrinkResources false
But still nothing. I am using flutter 2.10.5.
Flutter activity entry in my manifest file:
<activity
android:name=".MainFlutterActivity"
android:exported="true"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
I am making an app and the apk file that I am installing on my phone(API 23) using USB is not supporting on other devices(I have shared the apk and try to install it on a device of API 25).But another apk can be installed on that device using USB which is again not supporting on my phone.So,the apk of my app is not compatible.
And one more thing,the layouts are becoming different in different devices and sometimes 2 images are overlapping in one while in another device it is completely fine.
So I want to increase the compatibility of my app. Please help me out.
My manifest.xml file:
?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ankush.anthroplace.anthroplace">
<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=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="#string/title_activity_main"
android:theme="#style/AppTheme.NoActionBar" />
<activity android:name=".AboutUsActivity" />
<activity android:name=".TestimonialActivity" />
<activity android:name=".LoginActivity" />
<activity android:name=".RegisterActivity" />
<activity
android:name=".ServicesActivity"
android:label="#string/title_activity_services"
android:theme="#style/AppTheme.NoActionBar" />
<activity android:name=".FormActivity"></activity>
</application>
</manifest>
Check the API level you are targeting on your project.
If you're working with Android Studio, look on the file "build.gradle (Module: app)" and change the "minSdkVersion" attribute.
The lower the number you set on that attribute, the more compatible will be your app, but you should loose some features as well.
try to put minimum sdk API level 19.
by targeting minimum apk level 19 your app will run on approximately more than 90% of android devices.
and compile your app with the latest build tool
you can change minimum sdk version from build.gradle file
android {
compileSdkVersion 26
defaultConfig {
applicationId "profile.com.demotest"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Check Android Dashboard you will get better idea about choosing minimum api level
I have developed a android application . which is about maintaining the house . i have work with firebase in that application. now the problem is when i install that app in my android phone via usb cable from android studio it's run perfectly. but if i want share the app with someone via share it it's not working. (app not installed) a error come, why . ?? even if i am generate signed apk from android studio then it's also showing the same error . why ? any solution please.
and here the manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sonalirod.alwayswhite">
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<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" />
<application
android:allowBackup="true"
android:icon="#mipmap/lastfinalw"
android:label="#string/app_name"
android:roundIcon="#mipmap/lastfinalw"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".Firstscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Login" />
<activity android:name=".Interface" />
<activity android:name=".MainActivity" />
<activity android:name=".Bazar_Data_Input" />
<activity android:name=".MealEntry" />
<activity android:name=".Suggestion" />
<activity android:name=".admininterface" />
<activity android:name=".ALogin" />
<activity android:name=".AdminloginEnter" />
<activity android:name=".Showalldeposit"></activity>
</application>
</manifest>
gradle settings
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.sonalirod.alwayswhite"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
and i am trying to install in android 4.4.2 (api 19-20)
CommonsWare explained it all.
https://commonsware.com/blog/2017/10/31/android-studio-3p0-flag-test-only.html
Distributing APKs outside of GooglePlay to users need then to accept installing from Unknow Sources.
This options is under Settings > Security.. "Unknow sources"
Based in the link form other answer:
"
Android Studio 3.0 sets android:testOnly="true" on APKs that are run from the IDE
For many developers, this is of little consequence. However, if you have ever taken an APK lying around your build/ directory and sent it to somebody, that will only work if you did something other than run the app in Android Studio in order to create that APK, such as:
Built the app using the “Build APK(s)” menu option
Built the app using the assembleDebug or assembleRelease Gradle tasks
Built the app using something else that might use those tasks, such as a CI server
"
Are you building the application as release right?
My application works fine on Android 4, 5 and 6, when I plug devices to computer. But when I get .apk file from app/build/outputs/apk directory and install it directly, application crashes on Android 4 on start. Only on Android 4. Why? And how to fix it?
Here is my manifest file:
<manifest package="ru.pussy_penetrator.chgk"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
android:name=".QuestionGridActivity"/>
<activity
android:name=".QuestionPagerActivity"/>
</application>
Disable the Instant Run and Build the APK. Instant Run uses the device cache to hot swap the changes you make in the project. Also it optimizes the code to run on the platform that your testing device has.
You can also generate Signed apk for distributing across all the supported Android versions
Below manifest formation I am using into my project but whenever I am trying to run my emulator, I am getting below mentioned error. please give me a exact solution for solving the error.
Tools informations
Android studio
Nexus S API 22 (android 5.1.1)
My Manifest file formate
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.info.androidapp" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="app"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<!-- Splash activity -->
<activity
android:name=".SplashActivity"
android:label="app"
android:theme="#android:style/Theme.Holo.Light.NoActionBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Login activity -->
<activity
android:name=".LoginActivity"
android:label="app"
android:theme="#android:style/Theme.Holo.Light.NoActionBar.Fullscreen">
</activity>
<!-- List activity -->
<activity
android:name=".listActivity"
android:label="app"
android:theme="#android:style/Theme.Holo.Light.NoActionBar.Fullscreen">
</activity>
</application>
</manifest>
My Error :
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.info.androidapp/.SplashActivity }
Error type 3
Error: Activity class {com.example.info.androidapp/com.example.info.androidapp.SplashActivity} does not exist.
NOTE : Sometimes I am facing Unfortunately, the process com.android.phone has stopped alert into emulator!
After searching it for so long what helped me was.
1) File -> Sync Project with Gradle Files.
Or
This helped me too.
2) Uninstalling the previous installed application from emulator/mobile and re-run it and install it again.
Uninstall your app via 'adb' in the terminal: adb uninstall com.example.yourapp
I had to uninstall the app for all users.
If you have multiple users (e.g. a kids mode) on your device, uninstalling the app from homescreen only removes the app form the current user.
Go to Settings -> Apps -> (Your App) -> Open Popup Menu (by clicking on the three dots in top right corner) -> Uninstall for all Users
In build.gradle, the line:
apply plugin: 'android-library'
needs changed to:
apply plugin: 'android'
Edit:
Solution is deprecated. Please use this:
apply plugin: 'com.android.application'
try this
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.info.androidapp" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="app"
android:supportsRtl="true"
android:theme="#style/AppTheme" >
<activity
android:name=".SplashActivity"
android:label="app"
android:theme="#android:style/Theme.Holo.Light.NoActionBar.Fullscreen">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Login activity -->
<activity
android:name=".LoginActivity"
android:label="app"
android:theme="#android:style/Theme.Holo.Light.NoActionBar.Fullscreen">
</activity>
<activity
android:name=".listActivity"
android:label="app"
android:theme="#android:style/Theme.Holo.Light.NoActionBar.Fullscreen">
</activity>
</application>
</manifest>
your Main Launcher activity always should be only ONE Activity.
Include the applicationId configuration in build.gradle if it doesn't already exist.
android {
compileSdkVersion 18
buildToolsVersion '19.0.0'
defaultConfig {
applicationId 'com.myapp.app'
minSdkVersion 11
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
}
The solution to my problem was to uninstall an app from the app (Settings) folder in android because the app was just disabled.
I thing other solutoions will work fine for few user in my case i am using android 9 and i have multi user option enabled for system, it automatically install application for guest user, so goto
Settings>Apps>Concern App
And you will see uninstall for all user option at the top Option Menu. Uninstall and everything will work fine.
in my case this error sparsely appears in one project only and I can resolve it only uninstalling the app. the simplest way is to use Gradle:
ProjName->Tasks->install->uninstallAll
The Uninstall your app via 'adb' in the terminal: adb uninstall com.example.yourapp
worked fine for me