質問編集履歴

3

同じ質問と言われたため連番を振ってみました

2023/06/05 14:04

投稿

syosinsya109
syosinsya109

スコア41

test CHANGED
@@ -1 +1 @@
1
- androidのカルーセルについて
1
+ androidのカルーセルについて1
test CHANGED
File without changes

2

書式の改善

2023/06/05 12:58

投稿

syosinsya109
syosinsya109

スコア41

test CHANGED
File without changes
test CHANGED
@@ -10,13 +10,13 @@
10
10
  ### 発生している問題・エラーメッセージ
11
11
 
12
12
  ```
13
- java.lang.RuntimeException: Unable to start activity ComponentInfo{local.hal.st42.android.carouselsample/local.hal.st42.android.carouselsample.MainActivity}: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class com.synnapps.carouselview.CarouselView
13
+ java.lang.RuntimeException: Unable to start activity ComponentInfo{local.hal.st42.android.carouselsample/local.hal.st42.android.carouselsample.MainActivity}: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class com.synnapps.carouselview.CarouselView
14
14
 
15
- Caused by: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class com.synnapps.carouselview.CarouselView
16
- Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class com.synnapps.carouselview.CarouselView
17
- Caused by: java.lang.reflect.InvocationTargetException
15
+ Caused by: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class com.synnapps.carouselview.CarouselView
16
+ Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class com.synnapps.carouselview.CarouselView
17
+ Caused by: java.lang.reflect.InvocationTargetException
18
18
 
19
- Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/view/ViewPager$OnPageChangeListener;
19
+ Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/view/ViewPager$OnPageChangeListener;
20
20
 
21
21
  Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.view.ViewPager$OnPageChangeListener" on path: DexPathList[[zip file "/data/app/local.hal.st42.android.carouselsample-VV9TBEXEt4W0ehAMfiy1rA==/base.apk"],nativeLibraryDirectories=[/data/app/local.hal.st42.android.carouselsample-VV9TBEXEt4W0ehAMfiy1rA==/lib/arm64, /system/lib64, /system/vendor/lib64]]
22
22
 

1

進めていくうちに実行画面においてエラーが出てきたのでそのエラーの内容と該当のソースコードを変更しました。

2023/06/05 12:54

投稿

syosinsya109
syosinsya109

スコア41

test CHANGED
@@ -1 +1 @@
1
- androidのカルーセル
1
+ androidのカルーセルについて
test CHANGED
@@ -1,6 +1,6 @@
1
1
  ### 実現したいこと
2
2
 
3
- 以下のurlのようにカルーセルを作成しようと考えていますが、くビルドされなのかcom.synnapps.carouselview.CarouselViewを使おうとするとエラーが出てきす。
3
+ 以下のurlのようにカルーセルを作成しようと考えていますが、エラーが出てきてしまい実行できません。layoutファイルでエラーが出てきてそうなエラー文です。
4
4
 
5
5
  githubのurl
6
6
  https://github.com/sayyam/carouselview
@@ -10,23 +10,60 @@
10
10
  ### 発生している問題・エラーメッセージ
11
11
 
12
12
  ```
13
- Class referenced in the layout file, com.synnapps.carouselview.CarouselView, was not found in the project or the libraries
13
+ java.lang.RuntimeException: Unable to start activity ComponentInfo{local.hal.st42.android.carouselsample/local.hal.st42.android.carouselsample.MainActivity}: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class com.synnapps.carouselview.CarouselView
14
+
15
+ Caused by: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class com.synnapps.carouselview.CarouselView
16
+ Caused by: android.view.InflateException: Binary XML file line #20: Error inflating class com.synnapps.carouselview.CarouselView
17
+ Caused by: java.lang.reflect.InvocationTargetException
18
+
19
+ Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/view/ViewPager$OnPageChangeListener;
20
+
21
+ Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.view.ViewPager$OnPageChangeListener" on path: DexPathList[[zip file "/data/app/local.hal.st42.android.carouselsample-VV9TBEXEt4W0ehAMfiy1rA==/base.apk"],nativeLibraryDirectories=[/data/app/local.hal.st42.android.carouselsample-VV9TBEXEt4W0ehAMfiy1rA==/lib/arm64, /system/lib64, /system/vendor/lib64]]
22
+
23
+ at local.hal.st42.android.carouselsample.MainActivity.onCreate(MainActivity.java:22)
24
+
25
+ ここでエラーが出てきているっぽいです
14
26
  ```
15
27
 
16
28
  ### 該当のソースコード
17
29
 
18
- ```build.gradle
30
+ ```MainActivity
19
- dependencies {
31
+ import androidx.appcompat.app.AppCompatActivity;
20
32
 
33
+ import android.os.Bundle;
21
- implementation 'androidx.appcompat:appcompat:1.6.1'
34
+ import android.widget.ImageView;
22
- implementation 'com.google.android.material:material:1.5.0'
23
- implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
24
- testImplementation 'junit:junit:4.13.2'
25
- androidTestImplementation 'androidx.test.ext:junit:1.1.5'
26
- androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
27
35
 
28
- implementation 'com.synnapps:carouselview:0.1.5'
36
+ import com.synnapps.carouselview.CarouselView;
37
+ import com.synnapps.carouselview.ImageListener;
29
38
 
39
+ import java.util.ArrayList;
40
+ import java.util.List;
41
+
42
+ public class MainActivity extends AppCompatActivity {
43
+
44
+ List<Integer> images = new ArrayList<>();
45
+ CarouselView carouselView;
46
+
47
+ @Override
48
+ protected void onCreate(Bundle savedInstanceState) {
49
+ super.onCreate(savedInstanceState);
50
+ setContentView(R.layout.activity_main);
51
+
52
+ carouselView = findViewById(R.id.carouselView);
53
+ images.add(R.drawable.sake);
54
+ images.add(R.drawable.store);
55
+
56
+ carouselView.setPageCount(images.size());
57
+ carouselView.setImageListener(imageListener);
58
+ }
59
+
60
+ ImageListener imageListener = new ImageListener() {
61
+ @Override
62
+ public void setImageForPosition(int position, ImageView imageView) {
63
+ imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
64
+ imageView.setImageResource(images.get(position));
65
+ }
66
+ };
30
67
  }
31
68
  ```
32
69
  ```activity_main
@@ -48,15 +85,9 @@
48
85
  app:radius="6dp"
49
86
  app:slideInterval="3000"
50
87
  app:strokeColor="#FF777777"
51
- app:strokeWidth="1dp"/>
88
+ app:strokeWidth="1dp"
89
+ tools:ignore="MissingConstraints"/>
90
+
52
91
  </androidx.constraintlayout.widget.ConstraintLayout>
53
92
  ```
54
93
 
55
- ### 試したこと
56
-
57
- 以下のビルド方法を試してもエラーが変わりませんでした。
58
- また、最新バージョン0.1.6が出ているみたいですが、変えてもダメでした。
59
-
60
- 試したビルドの方法
61
- https://mvnrepository.com/artifact/com.synnapps/carouselview/0.1.5
62
-