Skip to content

Commit e4573a9

Browse files
author
Andrey Makarov
committed
1 parent d009177 commit e4573a9

37 files changed

+776
-5
lines changed

.gitignore

+3-5
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ captures/
3434

3535
# Intellij
3636
*.iml
37-
.idea/workspace.xml
38-
.idea/tasks.xml
39-
.idea/gradle.xml
40-
.idea/dictionaries
41-
.idea/libraries
37+
.idea/
4238

4339
# Keystore files
4440
*.jks
@@ -53,3 +49,5 @@ google-services.json
5349
freeline.py
5450
freeline/
5551
freeline_project_description.json
52+
53+
amplitude.properties

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
# Amplitude_issue_152_MCVE
22
An MCVE for https://github.com/amplitude/Amplitude-Android/issues/152
3+
4+
This example requires an `amplitude.properties` file to be added to the root of the project.
5+
This file must contain a line
6+
```
7+
amplitudeKey=your_amplitude_key
8+
```

app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

app/build.gradle

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
apply plugin: 'com.android.application'
2+
3+
def amplitudePropertiesFile = rootProject.file("amplitude.properties")
4+
5+
// Initialize a new Properties() object called keystoreProperties.
6+
def amplitudeProperties = new Properties()
7+
8+
// Load your keystore.properties file into the keystoreProperties object.
9+
amplitudeProperties.load(new FileInputStream(amplitudePropertiesFile))
10+
11+
android {
12+
compileSdkVersion 26
13+
defaultConfig {
14+
applicationId "com.makaroffandrey.amplitudetest"
15+
minSdkVersion 21
16+
targetSdkVersion 26
17+
versionCode 1
18+
versionName "1.0"
19+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
20+
buildConfigField 'String', 'AMPLITUDE_KEY', '"'+amplitudeProperties['amplitudeKey']+'"'
21+
}
22+
buildTypes {
23+
release {
24+
minifyEnabled false
25+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
26+
}
27+
}
28+
}
29+
30+
dependencies {
31+
implementation fileTree(dir: 'libs', include: ['*.jar'])
32+
implementation 'com.android.support:appcompat-v7:26.1.0'
33+
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
34+
implementation 'com.amplitude:android-sdk:2.15.0'
35+
testImplementation 'junit:junit:4.12'
36+
androidTestImplementation 'com.android.support.test:runner:1.0.1'
37+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
38+
}

app/proguard-rules.pro

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
22+
-keep class com.google.android.gms.ads.** { *; }
23+
-dontwarn okio.**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.makaroffandrey.amplitudetest;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumented test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("com.makaroffandrey.amplitudetest", appContext.getPackageName());
25+
}
26+
}

app/src/main/AndroidManifest.xml

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.makaroffandrey.amplitudetest">
4+
<uses-permission android:name="android.permission.INTERNET" />
5+
6+
<application
7+
android:name=".AmplitudeTestApplication"
8+
android:allowBackup="true"
9+
android:icon="@mipmap/ic_launcher"
10+
android:label="@string/app_name"
11+
android:roundIcon="@mipmap/ic_launcher_round"
12+
android:supportsRtl="true"
13+
android:theme="@style/AppTheme">
14+
<activity android:name=".FirstActivity">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN"/>
17+
18+
<category android:name="android.intent.category.LAUNCHER"/>
19+
</intent-filter>
20+
</activity>
21+
<activity android:name=".SecondActivity">
22+
</activity>
23+
</application>
24+
25+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.makaroffandrey.amplitudetest;
2+
3+
import android.app.Application;
4+
import android.util.Log;
5+
6+
import com.amplitude.api.Amplitude;
7+
8+
public class AmplitudeTestApplication extends Application {
9+
@Override
10+
public void onCreate() {
11+
super.onCreate();
12+
Amplitude.getInstance().initialize(this, BuildConfig.AMPLITUDE_KEY).enableForegroundTracking(this).enableLogging(true).setLogLevel(Log.VERBOSE);
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.makaroffandrey.amplitudetest;
2+
3+
import android.content.Intent;
4+
import android.support.v7.app.AppCompatActivity;
5+
import android.os.Bundle;
6+
import android.view.View;
7+
8+
import com.amplitude.api.Amplitude;
9+
10+
public class FirstActivity extends AppCompatActivity {
11+
12+
@Override
13+
protected void onCreate(Bundle savedInstanceState) {
14+
super.onCreate(savedInstanceState);
15+
if (savedInstanceState == null) {
16+
Amplitude.getInstance().logEvent("FirstActivity opened");
17+
}
18+
setContentView(R.layout.activity_first);
19+
findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
20+
@Override
21+
public void onClick(View view) {
22+
Amplitude.getInstance().logEvent("FirstActivity button pressed");
23+
startActivity(new Intent(FirstActivity.this, SecondActivity.class));
24+
}
25+
});
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.makaroffandrey.amplitudetest;
2+
3+
import android.support.v7.app.AppCompatActivity;
4+
import android.os.Bundle;
5+
6+
import com.amplitude.api.Amplitude;
7+
8+
public class SecondActivity extends AppCompatActivity {
9+
10+
@Override
11+
protected void onCreate(Bundle savedInstanceState) {
12+
super.onCreate(savedInstanceState);
13+
Amplitude.getInstance().logEvent("SecondActivity opened");
14+
setContentView(R.layout.activity_second);
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:width="108dp"
4+
android:height="108dp"
5+
android:viewportHeight="108"
6+
android:viewportWidth="108">
7+
<path
8+
android:fillType="evenOdd"
9+
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
10+
android:strokeColor="#00000000"
11+
android:strokeWidth="1">
12+
<aapt:attr name="android:fillColor">
13+
<gradient
14+
android:endX="78.5885"
15+
android:endY="90.9159"
16+
android:startX="48.7653"
17+
android:startY="61.0927"
18+
android:type="linear">
19+
<item
20+
android:color="#44000000"
21+
android:offset="0.0"/>
22+
<item
23+
android:color="#00000000"
24+
android:offset="1.0"/>
25+
</gradient>
26+
</aapt:attr>
27+
</path>
28+
<path
29+
android:fillColor="#FFFFFF"
30+
android:fillType="nonZero"
31+
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
32+
android:strokeColor="#00000000"
33+
android:strokeWidth="1"/>
34+
</vector>

0 commit comments

Comments
 (0)