【发布时间】:2021-11-17 23:08:48
【问题描述】:
我的 Flutter 代码:
onPressed: () async {
Geolocator
.getCurrentPosition(desiredAccuracy: LocationAccuracy.best, forceAndroidLocationManager: true)
.then((Position position) {
setState(() {
_currentPosition = position;
print ( "LAT: ${_currentPosition.latitude}, LNG: ${_currentPosition.longitude}");
});
}).catchError((e) {
print(e);
});
},
它显示以下内容:
`No location permissions are defined in the manifest. Make sure at least CCESS_FINE_LOCATION` or ACCESS_COARSE_LOCATION are defined in the manifest.
甚至以为我已经在清单中添加了权限
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.agent">
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<application
android:label="agent"
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">
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<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>
<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>
</manifest>
这里不允许使用属性 android:icon 未解决的类“MainActivity”
【问题讨论】:
-
卸载你的应用并运行flutter clean命令然后运行
-
同样的问题不起作用
-
你打开Flutter项目的文件夹了吗?打开Android项目文件夹怎么样?
标签: flutter dart android-manifest manifest flutter-android