opencv - Android Studio and Gradle dependency integration -
i'm following this tutorial android studio. have done following steps:
creating new project in android studio
adding opencv-2.4.5-sdk/sdk/java module
right clicked on main module->change module settings-> added above opencv module dependency
for mainactivity used following code (stripped down 1 of samples):
package com.example.test; import android.os.bundle; import android.app.activity; import android.util.log; import android.view.menu; import org.opencv.android.baseloadercallback; import org.opencv.android.camerabridgeviewbase; import org.opencv.android.camerabridgeviewbase.cvcameraviewlistener; import org.opencv.android.loadercallbackinterface; import org.opencv.android.opencvloader; import org.opencv.core.mat; public class mainactivity extends activity implements cvcameraviewlistener { private camerabridgeviewbase mopencvcameraview; private baseloadercallback mloadercallback = new baseloadercallback(this) { @override public void onmanagerconnected(int status) { switch (status) { case loadercallbackinterface.success: { log.i("yay", "opencv loaded successfully"); mopencvcameraview.enableview(); } break; default: { super.onmanagerconnected(status); } break; } } }; @override public void onresume() { super.onresume(); opencvloader.initasync(opencvloader.opencv_version_2_4_5, this, mloadercallback); } @override public void oncameraviewstarted(int width, int height) { } @override public void oncameraviewstopped() { } @override public mat oncameraframe(mat inputframe) { return null; } }
android studio's text editor identify packages have imported (like org.opencv.android) when compiled got these errors:
gradle: error: package org.opencv.android not exist gradle: error: package org.opencv.android not exist gradle: error: package org.opencv.android.camerabridgeviewbase not exist
does know why happens?
i having similar issue android studio on os x. write code, , android studio see .jar's referencing, , had declared dependencies on, when came time gradle build project, no go.
i opened 'build.gradle' file, , had manually add dependencies. example, here complete file:
buildscript { repositories { maven { url 'http://repo1.maven.org/maven2' } } dependencies { classpath 'com.android.tools.build:gradle:0.4' } } apply plugin: 'android' dependencies { compile files('libs/android-support-v4.jar') compile files('libs/gson-2.2.4.jar') compile files('libs/jsoup-1.7.2.jar') } android { compilesdkversion 17 buildtoolsversion "17.0.0" defaultconfig { minsdkversion 8 targetsdkversion 16 } }
as can guess, lines added ones referencing gson , jsoup.
Comments
Post a Comment