2016-08-26 59 views
0

enter image description here有点毛病的Android SDK源代码

enter image description here

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平台,谷歌的API,来源的Android SDK)的所有版本.RelativeLayout能不认识isLayoutRtl()属于它的超类View.It似乎RelativeLayout.java没有链接到View.java.Same事情发生在其他Class文件中。是否有我的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: enter image description here

enter image description here

+0

这似乎是一个链接问题。由于某些库或依赖关系存在问题,Android Studio并未完全编译该项目。尝试清理和重建项目,看看是否有任何奇怪的消息出现在消息日志 –

+0

您能请请分享错误消息 –

+0

gradlew -stacktrace并分享错误 –

回答

0

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

此外,即使没有太多关于isLayoutRTL()的文档,似乎该方法至少需要Android JellyBean才能使用它(您似乎正在瞄准)。

您可以在RelativeLayout的扩展到类和覆盖为自己advantag方法(如果你需要,当然)

@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; 
     } 
    } 
0

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

static boolean isLayoutRtl(View v) { 

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

}

+0

嗨,Suhayl SH.Thanks您的答案。但我想知道为什么这个问题出来了,是否有一些方法来解决这个问题。我曾经在Eclipse中的Android SDK源代码设置断点和断点工作正常,但它不能停止在正确的地方在AS.It很混乱。 – wanglugao

+0

@Ricardo维埃拉 – wanglugao