如果我在Flutter的geolocator: ^3.0.0
文件中添加了pubspec.yaml
,则我的Android应用无法生成并引发如下错误:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithMultidexlistForDebug'.
> com.android.build.api.transform.TransformException: Error while generating the main dex list.
我尝试将目标版本和buildtool版本从27更改为28仍然遇到相同的问题
build.gradle文件。
android {
compileSdkVersion 28
dexOptions {
javaMaxHeapSize "4g"
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
lintOptions {
disable 'InvalidPackage'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
multiDexEnabled true
applicationId "com.depl.toours.business"
minSdkVersion 16
targetSdkVersion 27
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
main.dart文件。
class MyDemoPage extends State<AccommodationPage> {
@override
void initState() {
super.initState();
propertyList = new List<String>();
propertyList.add('Hotel');
propertyList.add('Gust House');
_getCurrentPosition();
}
_getCurrentPosition() async{
GeolocationStatus status = await Geolocator().checkGeolocationPermissionStatus(locationPermission: GeolocationPermission.location);
print('GPS: $status');
Position position = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
double lat = position.latitude;
double lng = position.longitude;
print('LatLng: ${lat} & ${lng}');
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(
title: new Text('Accommodation'),
),
body: _getBody(),
);
}
}
我希望从geolocator: ^3.0.0
包中获得当前位置的坐标,并且在multidexEnabled true
(defaultConfig
文件)中包含build.gradle
。
答案 0 :(得分:0)
我认为您要么需要使用
export enum EGenderFormats {
SHORT_LOWER = "m/f",
SHORT_UPPER = "M/F",
FULL = "Male/Female"
}
type SGenderOptions = "m/f" | "M/F" | "Male/Female"
export interface IGenderOptions {
format: EGenderFormats | SGenderOptions;
}
const DEFAULTS: IGenderOptions = {
format: EGenderFormats.FULL
};
const OTHER_DEFAULTS: IGenderOptions = {
format: "M/F"
};
在您的设置中缺少此
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
}
...
}
或者如果您需要支持最小SDK <21
minSdkVersion 21
targetSdkVersion 28
在您的设置中缺少此
android {
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 28
multiDexEnabled true
}
...
}
dependencies {
compile 'com.android.support:multidex:1.0.3'
}
有关更多详细信息,请参见https://developer.android.com/studio/build/multidex