This is my first post on stack overflow so please be easy going here. It's also been a couple years since I've made an app so my conceptual understanding is not what it used to be.
My goal at the moment is to set up RTSP service for my mobile app.
I am having trouble getting the plugin I am using to connect to anything on the internet so one of my first debugging steps is to make sure the AndroidManifest.xml file is okay.
Below, is my AndroidManifest.xml file.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ad_hoc.ad_hoc">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:label="ad_hoc"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
Will the flutter build be effected if I have a few errors in my manifest file? I'm able to run the app, but I'm not sure if my internet permissions are working therefore I am unsure.
Here are the following errors I am getting in my manifest file:
"Unresolved class MainActivity" and "Attribute android:launchMode is
not allowed here"
The "is not allowed here" errors are occurring for multiple attributes. Should I resolve these or leave be? I've built new projects to see if this problem persists and it does. Not sure how to solve this.
For the unresolved class, I'm not sure how to get the manifest to recognize the main activity I use in my main.dart.xml file. The name of the primary Activity is not MainActivity.
Any pointers/help would be much appreciated.
Are there any simple tests that I can do to make sure that my app is able to connect to the internet?
So to summarize my question, will the internet permissions be granted although I have these problems in the manifest file?
Thank you!
Yes, when building or running on an android device the manifest will obviously have an effect on running the app. But - if your AndroidManifest.xml would really contain those errors the app would not launch in the first place.
My guess would be you either look at the wrong AndroidManifest.xml or your Android Studio has some problems. First make sure you are actually in the android module, and not in the root flutter project. ie. not in myproject/ but in myproject/android (in Android Studio you can use "Tools -> Flutter -> Open For Editing in Android Studio").
If you are really in the correct module, try to run from inside Android Studio which is opened from your Android app, not from the root folder. This might give you more error messages.
Also: by default the debug variants of the android manifest from the default flutter project template will include the internet permission. So if you don't change anything it's possible that the debug builds work, but the release builds are missing the internet permission.
Related
I've just upgraded to Flutter 2 and upgraded an application along with it. I followed all the steps to upgrade the application, but now I can't seem to run the app because my AndroidManifest.xml file seems corrupted.
Here is the xml file (I've also added comments where the errors are appearing).
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.finances_management">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:name="io.flutter.app.FlutterApplication" <-- Unresolved class 'FlutterApplication'
android:label="finances_management"
android:icon="#mipmap/ic_launcher"> <-- Cannot resolve symbol '#mipmap/ic_launcher'
<activity
android:name=".MainActivity" <-- Unresolved class 'MainActivity'
android:launchMode="singleTop"
android:theme="#style/LaunchTheme" <-- Cannot resolve symbol '#style/LaunchTheme'
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme" <-- Cannot resolve symbol '#style/NormalTheme'
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background" <-- Cannot resolve symbol '#drawable/launch_background'
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
I've seen elsewhere that people are just completely rebuilding their projects (as in completely generating a new project, stripping business logic from their Flutter 1.x app and copying it across to a Flutter 2.x app). Does anyone know what's happened to my XML file?
The best solution is to downgrade the Flutter . after that update AndroidManifest file
need some help I am just new to flutter and don't know what is the error on my AndroidManifest.xml file.In android:name="io.flutter.app.FlutterApplication" ,android:name=".MainActivity". also in Metadata has errors. I don't know if the file is corrupted or not, I have opened other Android flutter projects and it has all the same error on the AndroidManifest.xml file but the APP was running with no errors or anything. now the permissions I add is not working.
`
<uses-permission android:name="android.permission.ACCES_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCES_COARSE_LOCATION"/>
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="clima"
android:icon="#mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
`
That's normal because the Flutter SDK doesn't have code check for Android code. Even if there are warnings thrown from the Android code, you should still be able to run the Flutter app if the Android code doesn't have "real" errors.
What you can do here is to enable code completion for Java/Kotlin on Preferences > Language & Frameworks > Flutter > Experiments. This should remove the warnings thrown on the Android project even if the code is correct.
... or click on Tools > Flutter > Open Android module in Android Studio. This should open the Android build of the Flutter project on Android Studio and help check if the warnings given are correct.
I have used the https://pub.dev/packages/flutter_launcher_icons to generate my app icons. My pubspec.yaml is like this,
dependencies:
flutter_launcher_icons: ^0.8.0
flutter_icons:
android: "launcher_icon"
ios: true
image_path: "assets/icons/appIcon.png"
And my AndroidManifest.xml is
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.max.test_flutter_appppp">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="test_flutter_appppp"
android:icon="#mipmap/launcher_icon">
<activity
android:name=".MainActivity"
android:launchMode="singleTop"
android:theme="#style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="#style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="#drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
The app launcher icon is updated correctly but at certain places, the default flutter icon is shown.
Please see the screenshots below ,
The App icon is correctly shown in home screen but inside Settings/RecentApps and during installation, the default flutter icon is shown.
My Phone is Poco f1 and its running Android 10.
I suggest trying this website out to convert your images to App icons. In my personal experience, it has been great and seems to be the easiest way to change your app icon. Just go to this link https://appicon.co/ and upload your image. Select the devices you want to generate the icons for and download the archive.
Android
Then just go and copy all the folders (the mipmap stuff) in the android folder from the downloaded archive in your project\android\app\src\main\res\
iOS
Then just go and copy the Assets.xcassets from the downloaded archive in your project\ios\Runner\ and override the existing one there.
P.S. The converter also generates icons for Play Store and App Store.
Please make sure you have run your app in release mode.
if not then please uninstall your app and try it in release mode using flutter run --release command or profile mode using flutter run --profile command.
Then it should work.
Try adding this,
dependencies:
flutter_launcher_icons: ^0.8.0
flutter_icons:
android: true
ios: true
image_path: "assets/icons/appIcon.png"
Im trying to add upward navigation while following the beginners tutorial to android studio here. However, when I try to run it, it gives me the error:
Error running 'app':
Default Activity not found
The code in my AndroidManifest.xml file is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.myfirstapp">
<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=".DisplayMessageActivity"
android:parentActivityName=".MainActivity">
<!-- The meta-data tag is required if you support API level 15 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
</application>
</manifest>
There could be a number of things going on here. I would first suggest that you check all naming references to the layout and the code behind with a discerning eye. Sometimes with editing, you can inadvertently change and rename a file by adding or deleting letter in the name. Also, from time to time, when working with a IDE, a state of modification can go stale in which you can sometimes do a clean/build or a restart of the IDE. Pending updates to the IDE may be a culprit as well.
As a best practice, you should version your code. This will help alleviate most issues such as this. Check out the following link to Android's recommendations on this practice.
https://developer.android.com/studio/publish/versioning
I have arrived at Android Studio 3.0.0 (from the stable channel) via 3.0.0-rcX (from the Canary channel).
When I start a brand new app and build it, the following code (inside the app) shows that the FLAG_TEST_ONLY flag is set.
Log.e(TAG, "ApplicationInfo: " + (getApplicationInfo().flags & ApplicationInfo.FLAG_TEST_ONLY));
10-31 09:54:05.226 16129-16129/com.example.dummy E/MainActivity: ApplicationInfo: 256
The app's manifest is:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.dummy">
<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>
</application>
</manifest>
The flag stops Device Policy Controllers from being able to install it: Upgrading app in background using Device Policy Controller
Why is this flag set, and how to I stop it from being set?
I ran headlong into this the other day. Based on my testing, this flag is added only if you run the app from Android Studio. Unfortunately, the APK filename doesn't hint at the problem. And, despite the documentation, this APK is only usable from Android Studio — I specifically was trying to install it via adb, which is supposed to work, but doesn't.
If you build the APK in other ways, the flag should not be added. Specifically, I used the assembleRelease Gradle task. I would expect the "Build APK(s)" menu option in Android Studio to work as well.
Given Instant Run and other potential shenanigans that Android Studio might be doing for direct-run builds versus other ones, I am not surprised that they added this flag. Personally, I would love a clearer option to opt out of all such shenanigans (and perhaps this flag), as I'm one of those weirdos who wants the app that I run from the IDE to be the same app that my users run.
FWIW, I have more background on this at this blog post.