我不得不重新构建我的开发环境,现在我无法构建自己的android Java代码。 我还尝试删除了一些警告,因此更改了两个gradle选项。 主要变化是从R8转到D8
android.enableD8=true
代码:
package com.bsutton.sounds;
import android.Manifest;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.media.MediaPlayer;
import android.media.MediaRecorder;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
import android.os.SystemClock;
import android.support.v4.media.MediaBrowserCompat;
import android.support.v4.media.MediaMetadataCompat;
import android.support.v4.media.session.MediaControllerCompat;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v4.media.session.PlaybackStateCompat;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.arch.core.util.Function;
import androidx.core.app.ActivityCompat;
import android.media.AudioFocusRequest;
import java.io.*;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import io.flutter.embedding.engine.FlutterEngine;
import io.flutter.embedding.engine.plugins.FlutterPlugin;
mport io.flutter.embedding.engine.plugins.activity.ActivityAware;
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugin.common.MethodCall;
gradlew build
> Task :compileDebugJavaWithJavac FAILED
/home/bsutton/git/sounds/android/src/main/java/com/bsutton/sounds/ShadePlayer.java:63: error: package io.flutter.embedding.engine does not exist
import io.flutter.embedding.engine.FlutterEngine;
您可以在此处查看该项目:
https://github.com/bsutton/sounds
我的build.gradle
group 'com.bsutton.sounds'
version '1.0-SNAPSHOT'
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
}
}
rootProject.allprojects {
repositories {
google()
jcenter()
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 16 //24
}
lintOptions {
disable 'InvalidPackage'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.core:core:1.0.0'
implementation 'androidx.media:media:1.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0'
}
gradle.properties
org.gradle.jvmargs=-Xmx1536M
android.enableD8=true
android.useAndroidX=true
我已经尝试升级到最新的gradle版本。 我的Java 11确实有问题,但我更改了路径以指向Java 8
java -version
openjdk version "1.8.0_252"OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1ubuntu1-b09)OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
颤抖的医生
flutter doctor -v
[✓] Flutter (Channel stable, v1.17.4, on Linux, locale en_AU.UTF-8) • Flutter version 1.17.4 at /home/bsutton/apps/flutter
• Framework revision 1ad9baa8b9 (8 days ago), 2020-06-17 14:41:16 -0700 • Engine revision ee76268252 • Dart version 2.8.4
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
• Android SDK at /home/bsutton/Android/Sdk • Platform android-30, build-tools 30.0.0 • Java binary at: /home/bsutton/apps/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) • All Android licenses accepted.
[✓] Android Studio (version 4.0)
• Android Studio at /home/bsutton/apps/android-studio
• Flutter plugin version 46.0.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
答案 0 :(得分:0)
导入io.flutter.embedding.engine.FlutterEngine可能是解决方案。