这个SystemProperties类主要是在这个jar包中layoutlib.jar,所以现在的办法就是让这个 jar包加载到 android studio中

下面讲解如何添加:

1、找到对应项目的 build.gradle文件中,在 dependencies 中添加依赖,添加如下:

compileOnly files("D://Android/Sdk/platforms/android-19/data/layoutlib.jar")

注:如果按照网上说的使用provided时会提示这个方法已经过期,用compileOnly代替,由于我的项目是在android4.4上面,对应的API为19,所以就引用了android-19下面的layoutlib.jar文件。
上面文件路径我用的是绝对路径,为使项目在其它电脑上也可以正常使用,建议不要这么使用绝对路径,可以通过获取系统的环境变量,从而知道android sdk在哪个路径下,然后把layout.lib文件组合起来。

操作方法如下,直接贴上 build.gradle中的代码
 1 apply plugin: 'com.android.application' 2  3 android { 4     compileSdkVersion 28 5     defaultConfig { 6         applicationId "com.test.test" 7         minSdkVersion 19 8         targetSdkVersion 28 9         versionCode 110         versionName "1.0"11         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"12 13         //以下是为了找到android.os.SystemProperties这个隐藏的类14         String SDK_DIR = System.getenv("ANDROID_HOME")15         //("TAG", "SDK_DIR = " + SDK_DIR );16         if(SDK_DIR == null) {17             Properties props = new Properties()18             props.load(new FileInputStream(project.rootProject.file("local.properties")))19             SDK_DIR = props.get('sdk.dir');20 21     }22     buildTypes {23         release {24             minifyEnabled false25             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'26         }27     }28 }29 30 dependencies {31     implementation fileTree(dir: 'libs', include: ['*.jar'])32     compileOnly 'com.google.android.wearable:wearable:2.4.0'33     implementation 'com.google.android.support:wearable:2.4.0'34     implementation 'com.google.android.gms:play-services-wearable:16.0.1'35     implementation 'com.android.support:percent:28.0.0'36     implementation 'com.android.support:support-v4:28.0.0'37     implementation 'com.android.support:recyclerview-v7:28.0.0'38     implementation 'com.android.support:appcompat-v7:28.0.0'39     implementation 'com.android.support.constraint:constraint-layout:1.1.3'40     androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'41     testImplementation 'junit:junit:4.12'42     androidTestImplementation 'com.android.support.test:runner:1.0.2'43     compileOnly files("${SDK_DIR}/platforms/android-19/data/layoutlib.jar")44 45 }

2、然后在android studio中新建一个class文件,再输入到 import android.os.S...  的时候就会关联出SystemProperties,说明该 jar包引入成功

 

更多相关文章

  1. android ListView自定义适配器实现
  2. android studio 库工程添加变体功能
  3. Android(安卓)studio打包生成apk
  4. 解决S5pv210 adb push u-boot.bin /system 的失败问题
  5. Android从ftp服务器获取文件
  6. eclipse中绑定android源码
  7. android 按钮圆角
  8. android中的资源使用
  9. vitamio视频播放报错: java.lang.UnsatisfiedLinkError:dalvik.sy

随机推荐

  1. 数据库的CURD操作、PDO本质与原理的学习
  2. 字体图标的引用和自定义样式/媒体查询的
  3. HTML样式和常用选择器
  4. 字体图标的引入和通过媒体查询改变导航样
  5. 何搭建Android的开发环境->安装虚拟机篇(
  6. Android(安卓)敏感 API 的说明
  7. 浅谈Android的屏幕适配问题
  8. android 蓝牙
  9. Android实战(四)------Myeclipse10搭建an
  10. Android(安卓)-移动数据开发