我正在把我的pwa网站改成twa,我遇到了一些麻烦。
当我尝试同步或构建项目时,我遇到以下错误:
失败:生成失败,出现异常。
JAVAlang.NoClassDefFoundError(无错误消息)
我不熟悉android和java,有人能帮我吗?
我正在使用bubblewrap/cli我的gradle:
import groovy.xml.MarkupBuilder // ERROR : Cannot resolve symbol 'MarkupBuilder'
apply plugin: 'com.android.application'
def twaManifest = [
applicationId: 'br.com.estudoon.www.twa',
hostName: 'www.estudoon.com.br',
launchUrl: '/login',
name: 'Estudoon!',
launcherName: 'OON!',
themeColor: '#000000',
navigationColor: '#000000',
navigationColorDark: '#000000',
navigationDividerColor: '#000000',
navigationDividerColorDark: '#000000',
backgroundColor: '#FFFFFF',
enableNotifications: true,
shortcuts: [],
splashScreenFadeOutDuration: 300,
generatorApp: 'bubblewrap-cli', // Application that generated the Android Project
fallbackType: 'customtabs',
enableSiteSettingsShortcut: 'true',
orientation: 'any',
]
android {
compileSdkVersion 30
defaultConfig {
applicationId "br.com.estudoon.www.twa"
minSdkVersion 19
targetSdkVersion 30
versionCode 1
versionName "1"
resValue "string", "appName", twaManifest.name
resValue "string", "launcherName", twaManifest.launcherName
def launchUrl = "https://" + twaManifest.hostName + twaManifest.launchUrl
resValue "string", "launchUrl", launchUrl
resValue "string", "webManifestUrl", 'https://www.estudoon.com.br/manifest.json'
resValue "string", "hostName", twaManifest.hostName
twa#set_up_digital_asset_links_in_an_android_app
resValue "string", "assetStatements",
'[{ \\"relation\\": [\\"delegate_permission/common.handle_all_urls\\"],' +
'\\"target\\": {\\"namespace\\": \\"web\\", \\"site\\": \\"https://' +
twaManifest.hostName + '\\"}}]'
resValue "color", "colorPrimary", twaManifest.themeColor
resValue "color", "navigationColor", twaManifest.navigationColor
resValue "color", "navigationColorDark", twaManifest.navigationColorDark
resValue "color", "navigationDividerColor", twaManifest.navigationDividerColor
resValue "color", "navigationDividerColorDark", twaManifest.navigationDividerColorDark
resValue "color", "backgroundColor", twaManifest.backgroundColor
resValue "string", "providerAuthority", twaManifest.applicationId + '.fileprovider'
resValue "bool", "enableNotification", twaManifest.enableNotifications.toString()
twaManifest.shortcuts.eachWithIndex { shortcut, index ->
resValue "string", "shortcut_name_$index", "$shortcut.name"
resValue "string", "shortcut_short_name_$index", "$shortcut.short_name"
}
resValue "integer", "splashScreenFadeOutDuration", twaManifest.splashScreenFadeOutDuration.toString()
resValue "string", "generatorApp", twaManifest.generatorApp
resValue "string", "fallbackType", twaManifest.fallbackType
resValue "bool", "enableSiteSettingsShortcut", twaManifest.enableSiteSettingsShortcut
resValue "string", "orientation", twaManifest.orientation
}
buildTypes {
release {
minifyEnabled true
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
checkReleaseBuilds false
}
}
task generateShorcutsFile {
assert twaManifest.shortcuts.size() < 5, "You can have at most 4 shortcuts."
twaManifest.shortcuts.eachWithIndex { s, i ->
assert s.name != null, 'Missing `name` in shortcut #' + i
assert s.short_name != null, 'Missing `short_name` in shortcut #' + i
assert s.url != null, 'Missing `icon` in shortcut #' + i
assert s.icon != null, 'Missing `url` in shortcut #' + i
}
def shortcutsFile = new File("$projectDir/src/main/res/xml", "shortcuts.xml")
def xmlWriter = new StringWriter()
def xmlMarkup = new MarkupBuilder(new IndentPrinter(xmlWriter, " ", true))
xmlMarkup
.'shortcuts'('xmlns:android': 'http://schemas.android.com/apk/res/android') {
twaManifest.shortcuts.eachWithIndex { s, i ->
'shortcut'(
'android:shortcutId': 'shortcut' + i,
'android:enabled': 'true',
'android:icon': '@drawable/' + s.icon,
'android:shortcutShortLabel': '@string/shortcut_short_name_' + i,
'android:shortcutLongLabel': '@string/shortcut_name_' + i) {
'intent'(
'android:action': 'android.intent.action.MAIN',
'android:targetPackage': twaManifest.applicationId,
'android:targetClass': twaManifest.applicationId + '.LauncherActivity',
'android:data': s.url)
'categories'('android:name': 'android.intent.category.LAUNCHER')
}
}
}
shortcutsFile.text = xmlWriter.toString() + '\n'
}
preBuild.dependsOn(generateShorcutsFile)
repositories {
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.androidbrowserhelper:androidbrowserhelper:2.2.0'
}
编辑:我在任何项目中都遇到了相同的错误,即使是android Studio中的bult。已经重新安装了android Studio、XAMPP、java和node。
对于无法解析符号MarkupBuilder
:将groovy
类路径添加到构建中。如果使用的是
gradle 7
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.0'
classpath 'org.codehaus.groovy:groovy-xml:3.0.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
程序一直工作得很棒,但我不知道我的代码哪里出了问题,因为我的类都没有出现在堆栈跟踪中。
每当我尝试运行我的应用程序时,屏幕截图中的窗口就会弹出。声明找不到默认活动,因此我无法部署我的应用程序: 我的代码清单文件 这就是我点击运行时得到的窗口- 我的代码的Gradle文件:
android_home=c:\users\manish\appdata\local\android\sdk java_home=c:\program Files(x86)\java\jdk1.8.0_121子项目路径:CordovaLib为了支持这个构建的JVM设置,将分叉一个新的JVM。请考虑使用守护进程:https://docs.gradle.org/3.3/userguide/gradle
在使用美国蜂窝的手机上,我在核心库中发现了以下错误: 如何解决这个问题有什么建议吗?
我的应用程序https://github.com/amyequinn/weatherapp在终端运行npm启动时运行得很好,但是当将应用程序部署到Heroku时,它崩溃了,我找不到解决方案。错误为H10,应用程序在Get方法时崩溃,状态503.... “2020-05-08T23:13:34.132652+00:00 Heroku[router]:at=error code=h10 desc=”A
我有一个使用firebase显示广告的应用程序。问题是一些设备(似乎只有Android 4.4设备)崩溃。以下是坠机报告: 我猜这个错误可能与我的一些依赖项的版本有关。 以下是顶级渐变中的依赖项: 还有我的应用程序gradle: 任何提示都会有帮助!提前谢谢!