Untuk yang belum tau cara install OpenCV android bisa ikuti tutorial : Disini
MainActivity.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
package com.example.ivankoppong.coba; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.widget.TextView; import org.opencv.android.OpenCVLoader; public class MainActivity extends AppCompatActivity { // Used to load the 'native-lib' library on application startup. private static String TAG = "MainActivity"; static { if(OpenCVLoader.initDebug()){ Log.d(TAG, "OpenCv Sukses di Install"); }else { Log.d(TAG, "OpenCv Gagal di Install"); } } static { System.loadLibrary("native-lib"); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Example of a call to a native method TextView tv = (TextView) findViewById(R.id.sample_text); tv.setText(stringFromJNI()); } /** * A native method that is implemented by the 'native-lib' native library, * which is packaged with this application. */ public native String stringFromJNI(); } |
main_activity.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity"> <TextView android:id="@+id/sample_text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> </android.support.constraint.ConstraintLayout> |
Kemudian untuk mengetes apakah library OpenCV sukses di install atau belum dengan cara :
- Klik Logcat di bagian bawah kiri
- Di sebelah atas kanan samping regex pilih edite filter configuration
- Filter Name isi dengan nama “OpenCV”
- Log Tag isi dengan “MainActivity”
- Kemudian jalan aplikasi dengan kabel usb ke smartphone
- Setelah aplikasi berhasil terbuka (terinstall atau sudah running)
- Maka pada Logcat akan terdpat tulisan “OpenCv Sukses di Install”
Gan btw installasi Lib OpenCV itu, terisntallnya di android studionya apa di projek yang kita Build ?
Di projek yang kita build gan,,..setiap build projek install lagi OpenCV nya.
ERROR: The minSdk version should not be declared in the android manifest file
bang cara mengatasi error seperti diatas bagaimana?
Liat di manineft bahwa min sdk tidak dideklarasikan, atau liat build gradle