【问题标题】:Something wrong with Android SDK source codeAndroid SDK 源代码有问题
【发布时间】:2016-08-26 07:27:58
【问题描述】:

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 中的错误:

【问题讨论】:

  • 这似乎是一个链接问题。由于库或依赖项存在一些问题,Android Studio 未完全编译项目。尝试清理和重建项目,看看消息日志中是否出现任何奇怪的消息
  • 能否分享一下错误信息
  • gradlew -stacktrace 和共享错误
  • 编辑@RicardoVieira
  • 我用 gradle 代替 gradlew。看来 log@ahmadaghazadeh 中的每一个都很好

标签: java android android-studio android-sdk-manager


【解决方案1】:

根据您的信息,您的代码似乎没有错误。通常,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;
        }
    }

【讨论】:

    【解决方案2】:

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

     static boolean isLayoutRtl(View v) {
    
         return ViewCompat.getLayoutDirection(v) == ViewCompat.LAYOUT_DIRECTION_RTL;
    

    }

    【讨论】:

    • 嗨,Suhayl SH.thanks for your answer.But我想知道为什么会出现这个问题以及是否有办法解决这个问题。我曾经在eclipse的Android SDK源代码中设置断点并且断点工作正常,但它不能在 AS 中的正确位置停止。这非常令人困惑..
    猜你喜欢
    • 2012-02-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-05
    相关资源
    最近更新 更多