Help us understand the problem. What is going on with this article?

Androidアプリの.gitignore

More than 1 year has passed since last update.

基本的にはgitignore.ioで生成された内容で良かったのですが、1つだけエラーに遭遇したので共有させて頂きます。

ちなみに今回は、https://www.gitignore.io/api/macos,android,androidstudioを使いました。

発生したエラー

ローカルでは成功していたのですが、ビルドサーバでAndroidアプリをビルドしたところ、以下のエラーが発生しました。

Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain

エラーの原因

<project root>/gradle/wrapper/gradle-wrapper.jarが存在していないことが原因でした。

.gitignoreの見直し

gitignore.ioで生成した.gitignoreの中で影響がありそうな部分を抜粋します。

*.jar
!/gradle/wrapper/gradle-wrapper.jar

期待した動作をしそうですが、/gradle/wrapper/gradle-wrapper.jarが無視から除外されていませんでした。

.gitignoreを修正

以下のように修正することで対応できました。

*.jar
!gradle-wrapper.jar

最後に

.gitignoreの仕様を見る限り、最初の設定でも期待する動きをしそうですが、そうなりませんでした。

深く仕様を確認していないので、仕様として正しければ指摘頂けると幸いです。

gitignore.ioが生成するファイルも変わりそうなので、最後に全文載せておきます。

# Created by https://www.gitignore.io/api/macos,android,androidstudio

### Android ###
# Built application files
*.apk
*.ap_

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# Intellij
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/dictionaries
.idea/libraries

# Keystore files
*.jks

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild

# Google Services (e.g. APIs or Firebase)
google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

### Android Patch ###
gen-external-apklibs

### AndroidStudio ###
# Covers files to be ignored for android development using Android Studio.

# Built application files

# Files for the ART/Dalvik VM

# Java class files

# Generated files

# Gradle files
.gradle

# Signing files
.signing/

# Local configuration file (sdk path, etc)

# Proguard folder generated by Eclipse

# Log Files

# Android Studio
/*/build/
/*/local.properties
/*/out
/*/*/build
/*/*/production
*.ipr
*~
*.swp

# Android Patch

# External native build folder generated in Android Studio 2.2 and later

# NDK
obj/

# IntelliJ IDEA
*.iws
/out/

# User-specific configurations
.idea/libraries/
.idea/.name
.idea/compiler.xml
.idea/copyright/profiles_settings.xml
.idea/encodings.xml
.idea/misc.xml
.idea/modules.xml
.idea/scopes/scope_settings.xml
.idea/vcs.xml
.idea/jsLibraryMappings.xml
.idea/datasources.xml
.idea/dataSources.ids
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml

# Keystore files

# OS-specific files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Legacy Eclipse project files
.classpath
.project

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear

# virtual machine crash logs (Reference: http://www.java.com/en/download/help/error_hotspot.xml)
hs_err_pid*

## Plugin-specific files:

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Mongo Explorer plugin
.idea/mongoSettings.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

### AndroidStudio Patch ###
# Google Services plugin

!/gradle/wrapper/gradle-wrapper.jar

### macOS ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.TemporaryItems
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# End of https://www.gitignore.io/api/macos,android,androidstudio
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした