问题
For some reason my android project is not resolving any static paths to js / css / images while it works fine on web and ios. I am not using ionic, so maybe I am missing something specific? However all these files are available in android project.
Here is an image highlighting this issue, you can see that android app appears completely broken and only shows images that are base64 encoded. It has no styles applied not any js is working, it's just showing some html that was pre-rendered.
Arrow highlight that all these files are indeed being requested and are inside android folder
回答1:
This is really an Android "feature".
By default it doesn't copy assets folders starting with _
to the resulting apk (see https://android.googlesource.com/platform/frameworks/base/+/b41af58f49d371cedf041443d20a1893f7f6c840/tools/aapt/AaptAssets.cpp#60).
You can workaround it by adding custom aaptOptions
with the pattern to ignore, removing the _* so they get copied. Something like this:
aaptOptions {
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~'
}
It should go in the app's build.gradle
inside android -> defaultConfig
android {
...
defaultConfig {
...
aaptOptions {
ignoreAssetsPattern '!.svn:!.git:!.ds_store:!*.scc:!CVS:!thumbs.db:!picasa.ini:!*~'
}
}
}
来源:https://stackoverflow.com/questions/59156104/android-project-is-not-resolving-any-static-assets