Android Studio 3.0.1在Android.mk中注释掉行(Android Studio 3.0.1 commenting out lines in Android.mk)
是不是可以在Android Studio NDK项目的顶级Android.mk文件中注释行?
如果我删除下面显示的Hello.mk行,则不会出现错误。 如果我添加一个#然后我得到错误“这个文件不是项目的一部分。”
我该如何暂时删除此行(即将其注释掉)?
Is it not possible to comment out lines in the top-level Android.mk file of an Android Studio NDK project?
If I remove the Hello.mk line shown below, I get no errors. If I add a # then I get the error "This file is not part of the project."
How can I temporarily remove this line (i.e. comment it out) ?
原文:https://stackoverflow.com/questions/47878358
更新时间:2020-08-03 16:08
最满意答案
出于某种奇怪的原因,Android Studio会尝试将您的Android.mk视为C ++源代码。 您可以放心地忽略AS和AS显示的许多其他警告。
OTOH,您可以安全地删除该行,而不是在前面添加# :Android Studio会保存您编辑的文件的本地历史记录; 因此,您可以在需要时轻松恢复对此文件的任何更改。
For some weird reason Android Studio tries to treat your Android.mk as a C++ source. You can safely ignore this and many other warnings that AS displays.
OTOH, you can safely delete the line, instead of adding # in front: Android Studio keeps local history of the files that you edit thorough it; so, you can easily restore any changes to this file when you need that.
2017-12-19
相关问答
你的Android.mk文件应如下所示: JNI_DIR := $(call my-dir)
LOCAL_PATH:= $(JNI_DIR)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/ExtLibCurl/Android.mk
# Build main library as shared library.
LOCAL_PATH := $(JNI_DIR)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES += $(L
...
改变这一行: com.android.tools.build:gradle:2.3.3 至 com.android.tools.build:gradle:3.0.+
change this line: com.android.tools.build:gradle:2.3.3 to com.android.tools.build:gradle:3.0.+
出于某种奇怪的原因,Android Studio会尝试将您的Android.mk视为C ++源代码。 您可以放心地忽略AS和AS显示的许多其他警告。 OTOH,您可以安全地删除该行,而不是在前面添加# :Android Studio会保存您编辑的文件的本地历史记录; 因此,您可以在需要时轻松恢复对此文件的任何更改。 For some weird reason Android Studio tries to treat your Android.mk as a C++ source. You can
...
尝试以下方法 如果您的minSdkVersion设置为21或更高 android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 26
multiDexEnabled true
}
...
}
如果你的minSdkVersion设置为20或更低, android {
defaultConfig {
...
...
该问题描述了这个错误日志: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class android.support.v7.widget.Fab
Caused by: android.view.InflateException: Binary X
...
您可以手动设置JNI sourceSet,请参阅DSL参考 。 您还可以设置编译标志,过滤ABI,选择STL变体等。 You can set the JNI sourceSet manually, see the DSL reference. You can also set compilation flags, filter ABIs, choose STL variant, and more.
我想我在这里有一个解决方案。 它并不像我希望的那样漂亮(特别是因为它涉及创建一个临时文件),但我已经测试了它并且它按预期工作。 我写这个是为了使用另一个Application.mk进行调试构建,名为Application-debug.mk 。 你可以把APP_CFLAGS := -DENABLE_DEBUG放在里面做你想要的。 关于它如何工作的评论在代码中。 如果是应用程序构建文件,请使用applicationVariants.all而不是libraryVariants.all : android
...
解决方案是使用:LOCAL_AAPT_FLAGS + = --extra-packages {aar package name}。 你会得到两个R文件。 他们有一些内容。 一个人的包是主包,另一个是aar包。 The solution is use: LOCAL_AAPT_FLAGS += --extra-packages {aar package name}. You will get two R file. They has the some content. One's package is
...
如果你设置 android.sources{
main.jni {
source {
srcDirs = ['src/main/none'] // [] could be set instead but will disable even symbol resolution inside the editor
}
}
main.jniLibs {
source {
srcDirs
...
您需要将google()存储库添加到您的项目(root) build.gradle 。 像这样的东西: buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
allprojects {
repositories {
jcenter()
google()
...