Maybe this answer exists but I couldn't find it here nor google.
I have a static singleton class named Handler (non activity class). I added a library to my project and I would like to use the Handler in MainActivity of the library.
-- app
--java
--com.mytest
--Handler
-- library
--java
--com.mylib
--MainActivity
I've tried to import com.mytest.Handler in MainActivity but it didn't work. Maybe I should add some dependency to the library? I'm really lost.
EDITED:
MainActivity code:
public class MainActivity extends AppCompatActivity {
private Button mButtonMoreApps = null;
private ArrayList<String> mListUrl = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(com.mylib.R.layout.main_activity);
}
}
mylib gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
signingConfig signingConfigs.config
debuggable true
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso- core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "com.android.support:cardview-v7:25.3.1"
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:customtabs:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-core:10.2.1'
compile 'com.google.firebase:firebase-database:10.2.1'
compile 'com.google.firebase:firebase-ads:10.2.1'
compile 'com.google.firebase:firebase-crash:10.2.1'
compile 'com.facebook.android:audience-network-sdk:4.20.0'
compile ('com.facebook.android:facebook-android-sdk:4.20.0') // app invites
{
exclude group: 'com.android.support'
}
testCompile 'junit:junit:4.12'
}