首先在build.gradle写上方法
repositories {
mavenCentral()
maven {
url "http://dl.bintray.com/journeyapps/maven"
}
}
然后还是在这个文件内加上依赖
implementation 'com.journeyapps:zxing-android-embedded:2.0.1@aar'
implementation 'com.journeyapps:zxing-android-legacy:2.0.1@aar'
implementation 'com.journeyapps:zxing-android-integration:2.0.1@aar'
implementation 'com.google.zxing:core:3.0.1'
权限也是必须的
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
布局就搞一个BUTTON就好了
Activity里搞一下
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setCon