Add path valid check
The path valid check is added for avoiding panic message
Bug: 126612123
Test: tapas tradefed-all && make -j40
Change-Id: I76b79d5040db7168d8a8879f64349846005333b5
diff --git a/java/sdk_library.go b/java/sdk_library.go
index f2df49b..df4e08b 100644
--- a/java/sdk_library.go
+++ b/java/sdk_library.go
@@ -607,6 +607,10 @@
dir := filepath.Join("prebuilts", "sdk", v, api)
jar := filepath.Join(dir, module.BaseModuleName()+".jar")
jarPath := android.ExistentPathForSource(ctx, jar)
+ if !jarPath.Valid() {
+ ctx.PropertyErrorf("sdk_library", "invalid sdk version %q, %q does not exist", v, jar)
+ return nil
+ }
return android.Paths{jarPath.Path()}
}