我想从我的项目中得到.apk,但我的成绩有一个错误。我已经删除了我的.gradle
文件并重新安装了它,但是我仍然无法获得.apk。
我有这个:
android\app\src\main\AndroidManifest.xml:25: Error: AudioService must extend android.app.Service [Instantiatable]
<service android:name="com.ryanheise.audioservice.AudioService"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
H:\podkadeh\android\app\src\main\AndroidManifest.xml:35: Error: MediaButtonReceiver must extend android.content.BroadcastReceiver [Instantiatable]
<receiver android:name="com.ryanheise.audioservice.MediaButtonReceiver"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Explanation for issues of type "Instantiatable":
Activities, services, broadcast receivers etc. registered in the manifest
file (or for custom views, in a layout file) must be "instantiatable" by
the system, which means that the class must be public, it must have an
empty public constructor, and if it's an inner class, it must be a static
inner class.
2 errors, 0 warnings
Lint found fatal errors while assembling a release target.
To proceed, either fix the issues identified by lint, or modify your build script as follows:
...
android {
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:lintVitalRelease'.
> A failure occurred while executing com.android.build.gradle.internal.lint.AndroidLintTask$AndroidLintLauncherWorkAction
> There was a failure while executing work items
> A failure occurred while executing com.android.build.gradle.internal.lint.AndroidLintWorkAction
> Lint found fatal errors while assembling a release target.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 26s
Running Gradle task 'assembleRelease'... 27.1s
Gradle task assembleRelease failed with exit code 1
这里是我的AndroidManifest.xml
**:** ,我必须使用音频服务来播放背景…中的音频
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.podkadeh">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<application
android:name="io.flutter.app.FlutterApplication"
android:label="podkadeh"
android:icon="@mipmap/ic_launcher">
<activity
android:name="com.ryanheise.audioservice.AudioServiceActivity"
android:exported="true"
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">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<service android:name="com.ryanheise.audioservice.AudioService"
android:exported="true"
android:required="true"
>
<intent-filter>
<action android:name="android.media.browse.MediaBrowserService" />
</intent-filter>
</service>
<receiver android:name="com.ryanheise.audioservice.MediaButtonReceiver"
android:exported="true"
android:required="true"
>
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
<!-- 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>
这是我的build.gradle
buildscript {
ext.kotlin_version = '1.5.0'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
发布于 2022-01-23 21:54:19
在项目中包含的库com.ryanheise.audioservice
提供的示例程序包含一个成功编译的配置:https://github.com/ryanheise/audio_service/blob/minor/audio_service/example/android/app/src/main/AndroidManifest.xml
将xmlns:tools="http://schemas.android.com/tools"
添加为根节点<manifest>
中的属性
在tools:ignore="Instantiatable"
节点中添加属性android:exported="true" tools:ignore="Instantiatable"
,在<service>
节点和<receiver>
节点中添加android:exported="true" tools:ignore="Instantiatable"
。
https://stackoverflow.com/questions/70447775
复制相似问题