0

在此处输入图像描述

在此处输入图像描述

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.example.bigbaozi.myapplication"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }



}

我已经下载了所有版本的 API(Android SDK 文档、SDK 平台、Google APIs、Android SDK 源)。RelativeLayout 无法识别 isLayoutRtl() 属于它的超类 View。似乎 RelativeLayout.java 没有链接到 View.java。其他类文件中也发生了同样的事情。我的 AS(2.1.2) 有问题吗?

编辑:
重建项目:

Executing tasks: [clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:compileDebugSources, :app:compileDebugAndroidTestSources, :library:generateDebugSources, :library:generateDebugAndroidTestSources, :library:compileDebugSources, :library:compileDebugAndroidTestSources]

Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:clean UP-TO-DATE
:app:clean
:library:clean
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:library:preBuild UP-TO-DATE
:library:preReleaseBuild UP-TO-DATE
:library:compileReleaseNdk UP-TO-DATE
:library:compileLint
:library:copyReleaseLint UP-TO-DATE
:library:checkReleaseManifest
:library:preDebugAndroidTestBuild UP-TO-DATE
:library:preDebugBuild UP-TO-DATE
:library:preDebugUnitTestBuild UP-TO-DATE
:library:preReleaseUnitTestBuild UP-TO-DATE
:library:prepareComAndroidSupportSupportV42211Library
:library:prepareReleaseDependencies
:library:compileReleaseAidl
:library:compileReleaseRenderscript
:library:generateReleaseBuildConfig
:library:mergeReleaseShaders
:library:compileReleaseShaders
:library:generateReleaseAssets
:library:mergeReleaseAssets
:library:generateReleaseResValues UP-TO-DATE
:library:generateReleaseResources
:library:mergeReleaseResources
:library:processReleaseManifest
:library:processReleaseResources
:library:generateReleaseSources
:library:incrementalReleaseJavaCompilationSafeguard
:library:compileReleaseJavaWithJavac
:library:compileReleaseJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:library:extractReleaseAnnotations
:library:mergeReleaseProguardFiles UP-TO-DATE
:library:packageReleaseRenderscript UP-TO-DATE
:library:packageReleaseResources
:library:processReleaseJavaRes UP-TO-DATE
:library:transformResourcesWithMergeJavaResForRelease
:library:transformClassesAndResourcesWithSyncLibJarsForRelease
:library:mergeReleaseJniLibFolders
:library:transformNative_libsWithMergeJniLibsForRelease
:library:transformNative_libsWithSyncJniLibsForRelease
:library:bundleRelease
:app:prepareComAndroidSupportAnimatedVectorDrawable2340Library
:app:prepareComAndroidSupportAppcompatV72340Library
:app:prepareComAndroidSupportDesign2320Library
:app:prepareComAndroidSupportRecyclerviewV72330Library
:app:prepareComAndroidSupportSupportV42340Library
:app:prepareComAndroidSupportSupportVectorDrawable2340Library
:app:prepareMeEverythingOverscrollDecorAndroid103Library
:app:prepareMyApplicationLibraryUnspecifiedLibrary
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources
:app:mergeDebugResources
:app:processDebugManifest
:app:processDebugResources
:app:generateDebugSources
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareDebugAndroidTestDependencies
:app:compileDebugAndroidTestAidl
:app:processDebugAndroidTestManifest
:app:compileDebugAndroidTestRenderscript
:app:generateDebugAndroidTestBuildConfig
:app:mergeDebugAndroidTestShaders
:app:compileDebugAndroidTestShaders
:app:generateDebugAndroidTestAssets
:app:mergeDebugAndroidTestAssets
:app:generateDebugAndroidTestResValues UP-TO-DATE
:app:generateDebugAndroidTestResources
:app:mergeDebugAndroidTestResources
:app:processDebugAndroidTestResources
:app:generateDebugAndroidTestSources
:app:incrementalDebugJavaCompilationSafeguard
:app:compileDebugJavaWithJavac
:app:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources
:app:incrementalDebugAndroidTestJavaCompilationSafeguard
:app:compileDebugAndroidTestJavaWithJavac
:app:compileDebugAndroidTestJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:app:compileDebugAndroidTestNdk UP-TO-DATE
:app:compileDebugAndroidTestSources
:library:checkDebugManifest
:library:prepareDebugDependencies
:library:compileDebugAidl
:library:compileDebugRenderscript
:library:generateDebugBuildConfig
:library:mergeDebugShaders
:library:compileDebugShaders
:library:generateDebugAssets
:library:mergeDebugAssets
:library:generateDebugResValues UP-TO-DATE
:library:generateDebugResources
:library:mergeDebugResources
:library:processDebugManifest
:library:processDebugResources
:library:generateDebugSources
:library:prepareDebugAndroidTestDependencies
:library:compileDebugAndroidTestAidl
:library:compileDebugNdk UP-TO-DATE
:library:copyDebugLint UP-TO-DATE
:library:incrementalDebugJavaCompilationSafeguard
:library:compileDebugJavaWithJavac
:library:compileDebugJavaWithJavac - is not incremental (e.g. outputs have changed, no previous execution, etc.).
:library:extractDebugAnnotations
:library:mergeDebugProguardFiles UP-TO-DATE
:library:packageDebugRenderscript UP-TO-DATE
:library:packageDebugResources
:library:processDebugJavaRes UP-TO-DATE
:library:transformResourcesWithMergeJavaResForDebug
:library:transformClassesAndResourcesWithSyncLibJarsForDebug
:library:mergeDebugJniLibFolders
:library:transformNative_libsWithMergeJniLibsForDebug
:library:transformNative_libsWithSyncJniLibsForDebug
:library:bundleDebug
:library:compileDebugSources
:library:assembleDebug
:library:processDebugAndroidTestManifest
:library:compileDebugAndroidTestRenderscript
:library:generateDebugAndroidTestBuildConfig
:library:mergeDebugAndroidTestShaders
:library:compileDebugAndroidTestShaders
:library:generateDebugAndroidTestAssets
:library:mergeDebugAndroidTestAssets
:library:generateDebugAndroidTestResValues UP-TO-DATE
:library:generateDebugAndroidTestResources
:library:mergeDebugAndroidTestResources
:library:processDebugAndroidTestResources
:library:generateDebugAndroidTestSources
:library:incrementalDebugAndroidTestJavaCompilationSafeguard
:library:compileDebugAndroidTestJavaWithJavac
:library:compileDebugAndroidTestNdk UP-TO-DATE
:library:compileDebugAndroidTestSources

BUILD SUCCESSFUL

Total time: 2.63 secs

gradle -stacktrace(不是 gradlew):

To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/2.14/userguide/gradle_daemon.html.
Incremental java compilation is an incubating feature.
:help

Welcome to Gradle 2.14.

To run a build, run gradle <task> ...

To see a list of available tasks, run gradle tasks

To see a list of command-line options, run gradle --help

To see more detail about a task, run gradle help --task <task>

BUILD SUCCESSFUL

Total time: 5.413 secs

RelativeLayout.java 中的错误: 在此处输入图像描述

在此处输入图像描述

4

2 回答 2

0

使用以下定义创建您自己的方法:

 static boolean isLayoutRtl(View v) {

     return ViewCompat.getLayoutDirection(v) == ViewCompat.LAYOUT_DIRECTION_RTL;

}

于 2016-08-26T10:05:24.050 回答
0

根据您的信息,您的代码似乎没有错误。通常,Android SDK 类有一些与之关联的红色文本/警告,因为它只能在编译时链接它们。

此外,尽管没有太多关于isLayoutRTL()它的文档,但该方法似乎至少需要 Android JellyBean 才能使用它(您似乎是针对它的)。

您可以将 RelativeLayout 扩展到您的类并为您自己的优势覆盖该方法(当然,如果您需要)

@SuppressLint("NewApi")
    private boolean isLayoutRtl() {
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
            return View.LAYOUT_DIRECTION_RTL == getLayoutDirection();
        } else {
            return false;
        }
    }
于 2016-08-26T09:38:45.533 回答