Installing Dynamsoft Camera SDK manually

Step 1: Download the Dynamsoft Camera SDK

If you haven't downloaded the Dynamsoft Camera SDK Android Edition 30-day free trial, please download it here.

NOTE: You may need to sign in to download the trial.

Step 2: Create a new Android project in Android Studio

2.1 Create Android Project

2.2 Target Android Devices, choose API 19: Android 4.4 (KitKat)

2.3 Add an Activity to Mobile

2.4 Configure Activity

Step 3: Add Dynamosft Camera SDK to your project

3.1 Drag and drop DynamsoftCameraSDK{Version Number}.aar to libs folder.

3.2 Make changes to the build.gradle file.

repositories {

    flatDir {

        dirs 'libs'

    }

}


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    ……
    // Add the following lines
    implementation(name:'dynamsoftcamerasdk1.0.0',ext:'aar')
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'com.android.support:exifinterface:26.1.0'

}

Step 4: Add this permission to the AndroidManifest.xml

&ltuses-permission android:name="android.permission.CAMERA" /&gt
&ltuses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt
&ltuses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/&gt
&ltuses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt
&ltuses-permission android:name="android.permission.INTERNET"/&gt

For API 23 or higher, you need to manually request permissions for camera and SD card in your code. Below is the code snippet for your reference.

private static String[] PERMISSIONS_STORAGE = {
      "android.permission.READ_EXTERNAL_STORAGE",
      "android.permission.WRITE_EXTERNAL_STORAGE"};
private void requestPermissions() {
   if (Build.VERSION.SDK_INT > 22) {
      try {
         if (ContextCompat.checkSelfPermission(HelloWorld.this, "android.permission.WRITE_EXTERNAL_STORAGE") != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(HelloWorld.this, PERMISSIONS_STORAGE, 1);
         }
         if (ContextCompat.checkSelfPermission(HelloWorld.this, android.Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(HelloWorld.this, new String[]{android.Manifest.permission.CAMERA}, 10);
         }
      } catch (Exception e) {
         e.printStackTrace();
      }
   } else {
   }

}

Is this page helpful?

Leave a Reply

Your email address will not be published.