Merge "No abi diffing for vndk libraries which are not vendor available."
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 9d6f58e..f60463b 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -73,6 +73,10 @@
 	// list of of java libraries that will be in the classpath.
 	Libs []string `android:"arch_variant"`
 
+	// don't build against the framework libraries (legacy-test, core-junit,
+	// ext, and framework for device targets)
+	No_framework_libs *bool
+
 	// If set to false, don't allow this module(-docs.zip) to be exported. Defaults to true.
 	Installable *bool `android:"arch_variant"`
 
@@ -183,7 +187,9 @@
 		sdkDep := decodeSdkDep(ctx, String(j.properties.Sdk_version))
 		if sdkDep.useDefaultLibs {
 			ctx.AddDependency(ctx.Module(), bootClasspathTag, config.DefaultBootclasspathLibraries...)
-			ctx.AddDependency(ctx.Module(), libTag, []string{"ext", "framework"}...)
+			if Bool(j.properties.No_framework_libs) {
+				ctx.AddDependency(ctx.Module(), libTag, []string{"ext", "framework"}...)
+			}
 		} else if sdkDep.useModule {
 			ctx.AddDependency(ctx.Module(), bootClasspathTag, sdkDep.module)
 		}
diff --git a/java/java.go b/java/java.go
index ae48bd6..c4c07f7 100644
--- a/java/java.go
+++ b/java/java.go
@@ -571,13 +571,15 @@
 func (j *Module) collectDeps(ctx android.ModuleContext) deps {
 	var deps deps
 
-	sdkDep := decodeSdkDep(ctx, String(j.deviceProperties.Sdk_version))
-	if sdkDep.invalidVersion {
-		ctx.AddMissingDependencies([]string{sdkDep.module})
-	} else if sdkDep.useFiles {
-		// sdkDep.jar is actually equivalent to turbine header.jar.
-		deps.classpath = append(deps.classpath, sdkDep.jar)
-		deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, sdkDep.aidl)
+	if ctx.Device() {
+		sdkDep := decodeSdkDep(ctx, String(j.deviceProperties.Sdk_version))
+		if sdkDep.invalidVersion {
+			ctx.AddMissingDependencies([]string{sdkDep.module})
+		} else if sdkDep.useFiles {
+			// sdkDep.jar is actually equivalent to turbine header.jar.
+			deps.classpath = append(deps.classpath, sdkDep.jar)
+			deps.aidlIncludeDirs = append(deps.aidlIncludeDirs, sdkDep.aidl)
+		}
 	}
 
 	ctx.VisitDirectDeps(func(module android.Module) {
@@ -782,6 +784,7 @@
 		kotlinSrcFiles = append(kotlinSrcFiles, uniqueSrcFiles...)
 		kotlinSrcFiles = append(kotlinSrcFiles, srcFiles.FilterByExt(".kt")...)
 
+		flags.kotlincClasspath = append(flags.kotlincClasspath, deps.bootClasspath...)
 		flags.kotlincClasspath = append(flags.kotlincClasspath, deps.kotlinStdlib...)
 		flags.kotlincClasspath = append(flags.kotlincClasspath, deps.classpath...)